There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.

The input consists of a single line containing five integers c1, c2, c3, c4 and c5 — the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 ≤ c1, c2, c3, c4, c5 ≤ 100).

Print the only line containing a single positive integer b — the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).

NoteIn the first sample the following sequence of operations is possible:  One coin is passed from the fourth player to the second player;  One coin is passed from the fourth player to the fifth player;  One coin is passed from the first player to the third player;  One coin is passed from the fourth player to the second player.

s = [int(i) for i in input().split()]
a = sum(s)

if a%5!=0 or not a:
	print(-1)
else:
	print(a//5)

a = [int(i) for i in input().split()]
if sum(a) % 5 != 0 or sum(a) == 0:
    print(-1)
else:
    print(sum(a)//5)

s = sum(map(int, raw_input().split()))
print s / 5 if s % 5 == 0 and s / 5 else -1

li = list(map(int, input().split()))
if sum(li) < 5 or sum(li) % 5 != 0:
    print(-1)
else:
    print(int(sum(li) / 5))

a=[int(x) for x in raw_input().split()]
if sum(a)%5==0 and sum(a)!=0:
    print sum(a)/5
else:
    print -1

s = sum(map(int, raw_input().split(' ')))
print (s // 5) if s > 0 and s % 5 == 0 else -1

t=raw_input();
a=t.split(" ");
sum=0;
count=0;
for i in a:
    sum=sum+int(i);
    count=count+1;
if(sum>0):
    if(sum%count==0):
        print (sum/count);
    else:
        print "-1";
else:
    print "-1"

case=raw_input()
coins=case.split()
coins=[int(x) for x in coins]
pot=sum(coins)
if pot%5==0 and pot>0:
    print pot/5
else:
    print -1

C=input().rstrip().split(' ')
p=list(C)
S=0;
for i in range(0,len(p)):
    S+=int(p[i]);
G=0;
for i in range(1,101):
    if (i*5) == S:
        G=1;
        V=i;
        break;
if G==0:
    print(-1)
else:
    print(V);

a= []
a = map(int, raw_input().split())

sum = 0
for i in range(5):
	sum+=a[i]
if sum ==0:
	print(-1)
elif sum%5== 0:
	print(sum / 5)
else:
	print(-1)

def f1():
    n = map(int, raw_input().split())
    N = sum(n)
    if N == 0:
        print -1
    elif N % 5 == 0:
        print N / 5
    else:
        print -1
f1()

n=sum(list(map(int,input().split())))
print(-1 if n%5 or n==0 else n//5)

c1, c2, c3, c4, c5 = map(int, input().split())

s = c1 + c2 + c3 + c4 + c5

if not(s%5) and s != 0: print(int(s/5))
else: print(-1)

c=list(map(int,input().split()))
s=sum(c)
m,n=divmod(s,5)
if n==0 and m!=0:
    print(m)
else:
    print(-1)

a = map(int, raw_input().split())
if sum(a)%5==0 and sum(a)!=0:
	print sum(a)/5
else:
	print -1

final_bet=[int(i) for i in input().split()]
sum=0
for i in range(0,5,1):
    sum+=final_bet[i]

if sum>0 and sum % 5 == 0:
    print(int(sum/5))

else:
    print("-1")

#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil, factorial
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
from fractions import Fraction
from functools import reduce
import string
import sys
import os
import re
inf = float('inf')
mod_ = int(1e9) + 7
mod = 998244353

def factors(n):
    from functools import reduce
    return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sieve():
    n,m=1,10**6
    primes = {}
    arr=set([])
    for i in range(2, round(m ** 0.5) + 1):
        a = n // i
        b = m // i
        for k in range(max(2, a), b + 1):
            c = i * k
            primes[c] = 1

    for i in range(max(n, 2), m + 1):
        if i not in primes:
            arr.add(i)

    return arr

def main():
    # n,k=map(int,input().split())
    arr=list(map(int,input().split()))
    ans=sum(arr)
    # temp=ans
    if ans%5==0 and ans//5>0:
        print(ans//5)
    else:
        print(-1)

# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

x = raw_input()
lists = x.split(' ')
add = 0
for y in lists:
    add = add + int(y)
if add==0:
    print '-1'
elif add%5==0:
    print add/5
else:
    print '-1'

a = list(map(int, input().split()))
s=sum(a)
if s%5==0 and s>0:
    print(s//5)
else:
    print(-1)

# cook your dish here
n=list(map(int,input().rstrip().split()))

nn1=sum(n)

if nn1%5==0 and nn1>0:
    print(int(nn1/5))
else:
    print(-1)

a = [int(i) for i in input().split()]
a = sum(a)

if a%5==0 and a!=0:
    print(a//5)
else:
    print('-1')

l=list(map(int,input().split()))
print(sum(l)//len(l) if sum(l)%len(l)==0 and sum(l)!=0 else -1)

a,b,c,d,e=[int(t) for t in input().split()]
v=int((a+b+c+d+e)/5)
t=(a+b+c+d+e)%5
if t==0 and v!=0:
    print(v)
elif v==0:
    print(-1)
else:
    print(-1)

lista = list(map(int,input().split()))
mayor = max(lista)
bolsa = 0
find = False
val = 0
lista.sort()
for i in range(1,mayor+1):
    bolsa = 0
    for j in range(5):
        if i > lista[j]:
            bolsa-=i-lista[j]
        elif i < lista[j]:
            bolsa+=lista[j]-i
    if bolsa == 0:
        val = i
        find = True
        break

    if find:
        break
if find:
    print(i)
else:
    print('-1')

s = sum(map(int, raw_input().split(' ')))
print (s // 5) if s > 0 and s % 5 == 0 else -1

a = list(map(int, input().split()))
s = sum(a)
if s % 5 == 0 and s > 0:
    print(int(s/5))
else:
    print(-1)

a,b,c,d,e=map(int,input().split())
su=a+b+c+d+e
if(su%5==0 and su!=0):
	print(su//5)
else:
	print(-1)

initial = sum(list(map(int, input().split()))) / 5
print(int(initial)) if initial.is_integer() and initial > 0 else print(-1)

r = sum(map(int, raw_input().split()))
print -1 if r % 5 or r / 5 == 0 else r / 5

c1,c2,c3,c4,c5 = map(int,input().split())
x = c1+c2+c3+c4+c5
if x%5==0:
    if x==0:
        print(-1)
    else:
        print(x//5)
else:
    print(-1)

nums = [int(x) for x in input().split()]
print(sum(nums) // 5 if sum(nums) % 5 == 0 and sum(nums) != 0 else -1)

a,b,c,d,e=map(int,input().split())
s=a+b+c+d+e
if(s==0 or s%5):
    print(-1)
elif(s%5==0):
    print(s//5)

bet = sum(list(map(int , input().split())))
if bet%5!=0 or bet==0:
    print(-1)
else:
    print(bet//5)

c=list(map(int,input().split()))
x=len(c)
y=sum(c)
if y%x==0 and y!=0:
    print(y//x)
else:
    print(-1)

def solve(num):
    n = len(num)
    sum = 0
    for num in nums:
        sum += num

    return -1 if sum == 0 or sum % n != 0 else int(sum / n)

if __name__ == "__main__":
    nums = list(map(int, input().split(" ")))
    print(solve(nums))

n = list(map(int,raw_input().split()))
if sum(n) == 0:
    print -1
else:
    if sum(n)%len(n) == 0:
        print sum(n)/len(n)
    else:
        print -1

raw=input()

raw=raw.split(" ")
raw=[int(x) for x in raw]
a=0
for x in raw:
    a=a+x
if a==0:
    print(-1)
elif a % 5 !=0:
    print(-1)
else:
    print(int(a/5))

a = list(map(int, input().split()))
sm = sum(a)
if sm == 0:
    print(-1)
elif sm % 5 == 0:
    print(sm//5)
else:
    print(-1)

#
#   478A. Initial Bet
#

coins = list(map(int, raw_input().strip().split()))
if sum(coins) % 5 == 0 and sum(coins) != 0:
    print sum(coins) / len(coins)
else:
    print -1

c = map( int, raw_input().split() )
tot = sum( c )
if tot % len( c ) > 0 or tot == 0:
    print -1
    exit()
par = tot / len( c )
cnt = 0
for x in c:
    cnt += x - par
if cnt != 0:
    print -1
    exit()
print par

s = sum(map(int, raw_input().split()))
print s / 5 if s % 5 == 0 and s / 5 else -1

__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/478/A

Solution: Since every player is given same amount of coins, the total coins at the end of the game should still be
divisible by the total number of players. Check and return the result accordingly.
'''

def solve (num):

    n = len(num)
    sum = 0
    for num in nums:
        sum += num

    return -1 if sum == 0 or sum % n != 0 else sum / n

if __name__ == "__main__":

    nums = map(int,raw_input().split(" "))
    print solve(nums)

vlist=[int(x) for x in raw_input().split()]
if sum(vlist)%5==0 and sum(vlist)!=0:
    print sum(vlist)/5
else:
    print -1

c = [int(x) for x in input().split(' ')]

if sum(c) % len(c) == 0 and sum(c) > 0:
    ans = sum(c) // len(c)
else:
    ans = -1
print(ans)

x=[int(a) for a in input().split()]
if sum(x)!=0 and sum(x)%5==0:
  print(sum(x)//5)
else:
  print(-1)

l=lambda:map(int,raw_input().split())
a=l()
n=len(a)
s=sum(a)
if s>0 and s%n==0:
    print s/n
else:
    print '-1'

coins = input()
coins = coins.split()
coins = map(int, coins)

initial = 0
for num in coins:
    initial += num
initial = initial/5

if initial.is_integer():
	if int(initial) == 0:
		print(-1)
	else:
		print(int(initial))
else:
	print(-1)

a = [int(i) for i in input().split(" ")]
s = sum(a)
if (s % 5 == 0) and s > 0:
  print(s//5)
else:
  print(-1)

inp = [int(x) for x in input().split()]
x = sum(inp)

if x == 0:
    print(-1)
elif x % 5 == 0:
    print(x // 5)
else:
    print(-1)

import math
a=list(map(int,input().split()))
n=sum(a)
if( n>0 and n%5==0):
    print(int(n/5))

else:
    print("-1")

a = sum(map(int, input().split()))
if a % 5 or a // 5 == 0:
    print(-1)
else:
    print(a // 5)

a,b,c,d,e=map(int,input().split())
s=a+b+c+d+e
if(s==0 or s%5):
    print(-1)
elif(s%5==0):
    print(s//5)

c = map(int, raw_input().split(' '))

s = sum(c)

if (s % 5 != 0 or s == 0):
    print -1
else:
    print s / 5

r = sum(map(int, raw_input().split()))
print -1 if r % 5 or r / 5 == 0 else r / 5

# coding: utf-8
# (C) 2014, Laybson Plismenn / UFCG

bets = map(int, raw_input().split())

soma = sum(bets)

if soma == 0:
	print -1
elif soma % 5 == 0:
	print soma / 5
else:
	print -1

arr = list(map(int, input().strip().split()))
s = sum(arr)
if s % 5 == 0 and s//5 > 0:
	print(s//5)
else:
	print(-1)

cn = sum(map(int,input().split()))
print(cn//5 if cn%5 == 0 and cn>0 else '-1')

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 23 23:26:45 2020

@author: thiva
"""

C = [int(s) for s in input().split()]
if(sum(C) % 5 == 0 and sum(C) != 0):
    print(sum(C)//5)
else:
    print(-1)

line = [int(i) for i in input().split(" ")]
total = sum(line)
if total == 0 or total % 5 > 0:
    print(-1)
else:
    print(int(total/5))

n = list(map(int, input().split()))
if sum(n) % 5 == 0 and sum(n) != 0:
    print(sum(n) // 5)
else:
    print(-1)

a, b, c, d, e = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e= int(e)
f = a+b+c+d+e
if f%5!=0 or f ==0:
    print('-1')
else:
    print(int(f/5))

m = map(int, raw_input().split())
if (sum(m) % 5 == 0) and (sum(m) != 0):
    print sum(m) / 5
else:
    print -1

n = list(map(int,input().split()))
if sum(n)%5 == 0 and  sum(n) > 0 :
	print(sum(n)//5)
else :
	print(-1)

s = sum(map(int, raw_input().split()))
print [s / 5, -1][s % 5 != 0 or s == 0]

def main():
    coins = map(int, raw_input().split())
    sum_coins = sum(coins)
    return sum_coins / 5 if (sum_coins % 5 == 0 and sum_coins > 0) else -1

print main()

A=map(int,raw_input().split())
if sum(A)==0:
    print "-1"
    exit()

if sum(A)%5==0:
    print sum(A)/5
else:
    print "-1"

arr=[0]*99

arr=list(map(int, input().split()))

a=arr[0]
b=arr[1]
c=arr[2]
d=arr[3]
e=arr[4]

s = a + b + c + d + e

if s > 0 and s % 5 == 0:
    print(int(s / 5))
else:
    print(-1)

c = [int(i) for i in input().split()]
print([-1,sum(c)//len(c)][sum(c)%len(c)==0 and sum(c)!=0])

s=sum(map(int,raw_input().split()))
if s==0 or s%5!=0:print -1
else:print s//5

data_input=map(int,raw_input().split())
if len(set(data_input))==1 and data_input[0]==0:
	print '-1'
elif sum(data_input)%5==0:
	print sum(data_input)/5
else:
	print '-1'

l = list(map(int, input().split()))
if sum(l) % len(l) == 0 and sum(l) != 0:
    print(int(sum(l) / len(l)))
else:
    print('-1')

l=map(int,raw_input().split(' '))
if(sum(l)!=0 and sum(l)%5==0):
    print sum(l)/5
else:
    print -1

c1, c2, c3, c4, c5 = map(int, input().split())

s = c1 + c2 + c3 + c4 + c5

if not(s%5) and s != 0: print(int(s/5))
else: print(-1)

a,b,c,d,e=[int(x) for x in input().split()]
sum=a+b+c+d+e
if sum%5==0 and sum>=1:
    print(sum//5)
elif sum==0:
    print(-1)
else:
    print(-1)

ls = list(map(int,input().split()))
s = sum(ls)
print([s//5,-1][s%5 != 0 or not s])

vlist=[int(x) for x in raw_input().split()]
if sum(vlist)%5==0 and sum(vlist)!=0:
    print sum(vlist)/5
else:
    print -1

sum=eval(raw_input().replace(' ','+'))
print [-1,sum/5][sum%5==0 and sum>0]

c=[int(x) for x in input().split()]
if sum(c)%5==0 and sum(c) != 0:
    print(sum(c)//5)
else:
    print(-1)

n = sum(list(map(int, input().split())))
print(n//5 if n % 5 == 0 and n != 0 else -1)

a = map(int,raw_input().split())
a = reduce(lambda x,y:x+y,a)
print a/5 if a%5==0 and a!=0 else -1

li = list(map(int, input().split()))
if sum(li) < 5 or sum(li) % 5 != 0:
    print(-1)
else:
    print(int(sum(li) / 5))

temp = map(int,input().split(" "))
a1,a2,a3,a4,a5 = temp
t = a1 + a2 + a3 + a4 + a5
if t % 5 != 0:
    print(-1)
elif t == 0:
    print("-1")
else:
    print(int(t/5))

a,b,c,d,e=map(int,input().split())
s=a+b+c+d+e
if(s==0 or s%5):
    print(-1)
elif(s%5==0):
    print(s//5)

n=[int(z) for z in raw_input().split(' ')]

ans=sum(n)
if ans==0:
	result= -1
elif ans%5==0:
	result= ans/5
else:
	result= -1
print result

def main():
    s = sum([int(i) for i in raw_input().split()])
    if s == 0:
        print -1
    elif s%5 == 0:
        print s/5
    else:
        print -1

main()

a = [int(i) for i in input().split(" ")]
s = sum(a)
if (s % 5 == 0) and s > 0:
  print(s//5)
else:
  print(-1)

a=list(map(int,input().split()))
if sum(a)%5==0 and sum(a)>0 and all(i>=0 for i in a):
    print(sum(a)//5)
else:
    print(-1)

# A. Initial Bet

a, b, c, d, e = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)

if ((a+b+c+d+e)%5 == 0) and a+b+c+d+e != 0:
    print(int((a+b+c+d+e)/5))
else:
    print("-1")

b = sum([int(x) for x in input().split()])
print(int(b / 5) if (b > 0) and (b % 5 == 0) else -1)

a = sum(map(int, input().split()))
if a % 5 == 0:
    print(a // 5)
else:
    print(-1)

Jugadores=map(int,raw_input().split())
suma=0
Cantidad=len(Jugadores)
for k in range (Cantidad):
    suma+=Jugadores[k]
if (suma==0):
    print 0
else:
    if(suma%Cantidad==0):
        print suma/Cantidad
    else:
        print -1

li = list(map(int, input().split()))
if 0 not in li and sum(li) < 5:
    print(-1)
else:
    print(int(sum(li) / 5))

arr=list(map(int,input().split()))
sum=0
for i in arr:
    sum+=i
if sum%5==0:
    print(int(sum/5))
else:
    print(-1)

l = list(map(int, input().split()))
if sum(l)%len(l)==0:
    print(int(sum(l)/len(l)))
else:
    print('-1')

def main():
    s = sum(list(map(int, input().split(' '))))
    ss = s // 5
    return ss if ss * 5 == s else -1
print(main())

bets = [int(x) for x in input().split()]
if sum(bets) % 5 == 0:
    print(sum(bets)//5)
else:
    print(-1)

# your code goes here
arr=[int(x) for x in input().split()]
s=sum(arr)
if s%5==0:
	print(s//5)
else:
	print("-1")

a = input()
stop1 = a.find(" ")
stop2 = a.find(" ", stop1+1)
stop3 = a.find(" ", stop2+1)
stop4 = a.find(" ", stop3+1)
f = int(a[:stop1])
b = int(a[stop1+1:stop2])
c = int(a[stop2+1:stop3])
d = int(a[stop3+1:stop4])
e = int(a[stop4+1:])
print((f+b+c+d+e)//5)

coins = input()
coins = coins.split()
coins = map(int, coins)

initial = 0
for num in coins:
    initial += num
initial = initial/5

if initial % 5 != 0:
    print(-1)
else:
    print(initial)

a=[int(i) for i in input().split()]
i=0
h=0
while i<len(a):
    h=h+a[i]
    i+=1

a=map(int,raw_input().split())
if sum(a)%5 : print -1
else : print sum(a)//5

# A. Initial Bet

a, b, c, d, e = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)

if (a+b+c+d+e)%5 == 0:
    print(int((a+b+c+d+e)/5))
else:
    print("-1")

#-*- encoding:utf-8 -*-

'''
5명의 플레이어
같은 동전을 걸고, 1개씩 동전을 다른 플레이어에게 전달(반복)

입력
마지막에 가지고 있는 동전 개수
출력
초기 배팅값(불가능 -1)

'''

a, b,c,d,e = map(int, raw_input().split())

if (a+b+c+d+e)%5 == 0 or (a+b+c+d+e) == 0:
	print (a+b+c+d+e)/5
else :
	print -1

def main():

    L = [ int(i) for i in raw_input().split(" ") ]
    s = sum(L)

    if len(L) % s != 0:
        print -1
    else:
        print len(L)/s

main()

l=lambda:map(int,raw_input().split())
a=l()
n=len(a)
s=sum(a)
if s%n==0:
    print s/n
else:
    print '-1'

filename = "input1.txt"
import sys
caonima = True
if caonima:
    f = sys.stdin
else:
    f = open(filename)

a = map(int,f.readline().split())
if sum(a)%3:
    print -1
else:
    print sum(a)/len(a)

#with open( "2.out", "w") as f1:
#    for i in ans:
#        j = str(i)+'\n'
        #print j
#        f1.write(j)

c=list(map(int,input().split()))
if sum(c)%5==0:
    print(sum(c)//5)
else:
    print(-1)

import math
import sys,collections
from sys import stdin, stdout
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)]
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x
def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if (spf[i] == i):
			for j in range(i * i, MAXN, i):
				if (spf[j] == j):
					spf[j] = i
def getFactorization(x):
	ret = list()
	while (x != 1):
		ret.append(spf[x])
		x = x // spf[x]

	return ret
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1

    return ind
def check(st) :

    # Compute sum of digits
    n = len(st)
    digitSum = 0

    for i in range(0,n) :
        digitSum = digitSum + (int)(st[i])

    # Check if sum of digits
    # is divisible by 9.
    return (digitSum % 9 == 0)
def isPowerOfTwo(n):
    if (n == 0):
        return False
    while (n != 1):
            if (n % 2 != 0):
                return False
            n = n // 2

    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c

#file()
#sieve()
mod=(10**9)+7
def main():
	l=get_array()
	if(len(set(l))==1):
		if(l[0]==0):
			print(0)
			exit()
	if(sum(l)%5==0):

		print(sum(l)//5)
	else:
		print(-1)

if __name__ == '__main__':
    main()

a = list(map(int,input().split()))
s = sum(a)
if s % 5 == 0:
  print(s//5)
else:
  print(-1)

import sys
import math
import bisect

def main():
    A = list(map(int, input().split()))
    n = len(A)
    if sum(A) % n == 0:
        print(sum(A) // n)
    else:
        print(-1)

if __name__ == "__main__":
    main()

li = list(map(int, input().split()))
print([sum(li)//5, '-1'][sum(li)%5 != 0])

nums = [int(x) for x in input().split()]
print(sum(nums) // 5 if sum(nums) % 5 == 0 and sum(nums) == 0 else -1)

l=list(map(int,input().split()))
if(sum(l)==0):
    print("0")
else:
    if (sum(l) % 5 == 0):
        print(int(sum(l) / 5))
    else:
        print("-1")

from __future__ import division
from collections import Counter as ctr
from math import ceil, log, factorial, sqrt
# reads a line of input and converts into a list of ints
# 1 1 3 => [1, 1, 3]
def rl():
    return [int(i) for i in raw_input().split()]

# reads n lines of input (if n defined) and returns a list of strings
# where each element is a line in the input
# abc
# abcdef
# => ['abc', 'abcdef']
# if n not defined, read first line to get number of lines
# 2
# abc
# abcdef
# => ['abc', 'abcdef']
def rm(n=None):
    if n is None:
        n = input()
    return [raw_input() for i in range(n)]

# same as rm, except converts each line to a list of ints like rl
def rlm(n=None):
    if n is None:
        n = input()
    return [rl() for i in range(n)]

def yn(b):
    if b:
        print "YES"
    else:
        print "NO"

n = rl()
s = sum(n)
avg = s//len(n)
if s == 0 or s % avg != 0:
    print -1
else:
    print avg

a=[int(i) for i in input().split()]
d=sum(a)
if(d%len(a)==0):
    print(d//len(a))
else:
    print(-1)

l=list(map(int,input().split()))
if(sum(l)%5==0):
    print(int(sum(l)/5))
else:
    print("-1")

coins = input()
coins = coins.split()
coins = map(int, coins)

initial = 0
for num in coins:
    initial += num
initial = initial/5

if initial.is_integer():
    print(int(initial))
else:
    print(-1)

#!/usr/bin/python2.7
n = sum(map(int, raw_input().split()))
if n % 5: print -1
else: print n / 5

coins = [int(n) for n in raw_input().split()]

soma = sum(coins)

if soma%5==0:
	print soma/5
else:
	print -1

ls = [int(i) for i in input().split()]

val = sum(ls)

initial = val//len(ls)
if val==0:
    print("0")
elif initial*len(ls)==val:
    print(initial)
else:
    print("-1")

a = sum(map(int,raw_input().split()))
print ['-1',a/5][a%5 == 0 or a == 0]

x= input().split()
s=0
for i in x:
    s+=int(i)
if (s/5)-int(s/5) == 0:
    print(int(s/5))
else:
    print(-1)

def main():
    s = sum([int(i) for i in raw_input().split()])
    if sum == 0:
        print -1
    elif s%5 == 0:
        print s/5
    else:
        print -1

main()

bet = [int(i) for i in raw_input().split()]
res = sum(bet)
if res % 5 == 0:
  print res / 5
else:
  print -1

Jugadores=map(int,raw_input().split())
suma=0
Cantidad=len(Jugadores)
for k in range (Cantidad):
    suma+=Jugadores[k]
if(suma%Cantidad==0):
    print suma/Cantidad
else:
    print -1

a=list(map(int,input().split()))

x=max(a)
y=min(a)

for i in range (y,x+1):
	t=[j-i for j in a]
	if(sum(t)==0):
		print(i)
		break
else:
	print("-1")

a = [int(i) for i in input().split()]
if sum(a) % 5 == 0:
    print(sum(a) // 5)
elif sum(a) == 0:
    print(0)
else:
    print(-1)

'''
CF problem 478A
@autor Yergali B
'''
a=list(map(int,input().split()))
b=sum(a)
if b%5==0:
    print(b//5)
else:
    print(-1)

sum_=sum(map(int,raw_input().split()))
if sum_%5==0 or sum_<>0:
    print sum_/5
else:
    print -1

x= input().split()
s=0
for i in x:
    s+=int(i)
if s == 0 :
    print(0)
elif (s/5)-int(s/5) == 0:
    print(int(s/5))
else:
    print(-1)

a,b,c,d,e=[int(x) for x in input().split()]
sum=a+b+c+d+e
if sum%5==0:
    print(sum//5)
else:
    print(-1)

import math
a=list(map(int,input().split()))
n=sum(a)
if(n%5==0):
    print(int(n/5))
elif(n==0):
    print("0")
else:
    print("-1")

numbers = map(int, raw_input().split())
sum = 0
for i in numbers:
	sum += i
	if i > 100:
		print -1
		exit()
	if i < 0:
		print -1
		exit()
mod = sum % 5
if mod != 0:
	print -1
else:
	print sum/5

y = sum(map(int,raw_input().split()))
if y%5==0:
    print y/5
else:
    print -1

c=list(map(int,input().split()))
if sum(c)%5==0:
    print(sum(c)//5)
else:
    print(-1)

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 23 23:26:45 2020

@author: thiva
"""

C = [int(s) for s in input().split()]
if(sum(C) % 5 == 0):
    print(sum(C)//5)
else:
    print(-1)

n = list(map(int,input().split()))
if sum(n)%5 == 0 or  sum(n) == 0 :
	print(sum(n)//5)
else :
	print(-1)

pet = [int(z) for z in input().split()]
x = sum(pet)%pet.__len__()
if(x == 0):
	print(sum(pet)//pet.__len__())
else:
	print('-1')

a = [int(i) for i in input().split()]
a = sum(a)

if a%5==0:
    print(a//5)
else:
    print('-1')

l = [int(x) for x in raw_input().split()]
sl = sum(l)
m = sl%5
if not m:
    print sl/5
else:
    print -1

x= input().split()
s=0
for i in x:
    s+=int(i)
if (s/5)-int(s/5) == 0:
    print(int(s/5))
else:
    print(-1)

a=[int(x) for x in raw_input().split()]
if sum(a)%5==0:
    print sum(a)/5
else:
    print -1

num = input()
arr = []
count = 0
for i in range(0,len(num)):
    if num[i] == ' ':
        arr.append(int(num[count:i]))
        count = i+1
    elif  i == len(num)-1:
        arr.append(int(num[count:len(num)]))

counting = 0
for i in arr:
    counting += i

if counting%len(arr) == 0:
    print(int(counting/len(arr)))
else:
    print(-1)

l=map(int,raw_input().split(' '))
if(sum(l)%5==0):
    print sum(l)/5
else:
    print -1

a,b,c,d,e=map(int,input().split())
s=a+b+c+d+e
if(s%5==0 or s==0):
    print(-1)
elif(s%5==0):
    print(s//5)

import math
l=list(map(int,input().split()))
n=sum(l)/len(l)
if n%1:
     print(-1)
else:
     if n<=max(l):
          print(math.floor(n))
     else:
          print(-1)

a,b,c,d,e=[int(t) for t in input().split()]
v=int((a+b+c+d+e)/5)
t=(a+b+c+d+e)%5
if t==0:
    print(v)
else:
    print(-1)

n=list(map(int,input().split()))
la=list(range(min(n),max(n)+1))
for item in la:
    b=0
    j=0
    for x in n:
        if item-x>0:
            b+=item-x
        else:
            j+=x-item
    if b==j:
        print(item)
        break

raw=input()

raw=raw.split(" ")
raw=[int(x) for x in raw]
a=0
for x in raw:
    a=a+x
if a==0:
    print(0)
elif a % 5 !=0:
    print(-1)
else:
    print(int(a/5))

a,b,c,d,e=[int(x) for x in input().split()]
sum=a+b+c+d+e
if sum%5==0:
    print(sum//5)
else:
    print(-1)

'''input
4 5 9 2 1
'''
s = sum(list(map(int, input().split())))
if s % 5 == 0:
	print(s//5)
else:
	print(-1)

import string
import math

x=0
a = str(input(""))
s= str(a.replace(" ",""))

for i in range(5):
	x= int(s[i])+ x

if x%5==0 and x!=0:
	print(int(x/5))
else:
	print(-1)

a = sum([int(i) for i in input().split(' ')])
print((a//5) if (a%5) == 0 else -1)

a = list(map(int, raw_input().split(" ")))

s = 0

for i in range(len(a)):
    s+= a[i]

if s % len(a) == 0:
    print s/len(a)
else:
    print "-1"

a=list(map(int, input().split()))
s=sum(a)
if not s%5:
	print(s//5)
else:
	print(-1)

x= input().split()
s=0
for i in x:
    s+=int(i)
if s == 0 :
    print(0)
elif (s/5)-int(s/5) == 0:
    print(int(s/5))
else:
    print(-1)

a = input().split(' ')
for i in range(len(a)):
    a[i] = int(a[i])
sums = a[0] + a[1] + a[2] + a[3] + a[4]
if sums % 5 == 0:
    print(int(sums // 5))
else:
    print("-1")

l = [int(x) for x in input().split()]
s = sum(l)
d = s/5
if d=="0":
    print("-1")
elif d-(s//5)>0:
    print("-1")
else:
    print(int(d))

sum=eval(raw_input().replace(' ','+'))
print [-1,sum/5][sum%5==0]

lst=list(map(int,input().split()))
print('-1' if sum(lst)%5 else sum(lst)//5)

a,b,c,d,e=map(int,input().split())
n=(a+b+c+d+e)
if n%5!=0:
    print(-1)
else:
    print(n/5)

#------------------------------what is this I don't know....just makes my mess faster--------------------------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#----------------------------------Real game starts here--------------------------------------
c = list(map(int, input().split()))
if sum(c) % 5 == 0:
    print(int(sum(c)/5))
else:
    print(-1)

inp = raw_input().strip().split()

total = 0
for i in range(0,len(inp)):
    a = int(inp[i])
    total += a

m = total % 5
x = total / 5

if m == 0:
    print x
else:
    print -1

# Task to find intitial bet.
#
#
#
# Output:
#	bet_size(int) - the amount of initail bet.

def main():
	bets = list(map(int, input().split()))
	print(bets)
	if sum(bets) % 5 == 0:
		print(int(sum(bets) / 5))
	else:
		print(-1)

if __name__ == "__main__":
	main()

a = input().split(' ')
for i in range(len(a)):
    a[i] = int(a[i])
sums = int(a[0] + a[1] + a[2] + a[3] + a[4])
if sums % 5 == 0:
    print(int(sums // 5))
else:
    print("-1")

x = raw_input()
lists = x.split(' ')
add = 0
for y in lists:
    add = add + int(y)
if add%5==0:
    print add/5
else:
    print '-1'

c1, c2, c3, c4, c5 = [int(i) for i in input().split()]
s = c1 + c2 + c3 + c4 + c5
if s % 5 == 0:
    print(s // 5)

else:
    print(-1)

n=list(map(int,input().split()))

if sum(n)%5==0 :
	print(sum(n)//5)
else :
	print(-1)

# your code goes here

a,b,c,d,e = map(int,raw_input().split())
sum1 = a+b+c+d+e
if sum1%5 == 0:
	print sum1/5
else:
	print -1

l= list(map(int,input().split()))

s=sum(l)
if s%5==0:
    print(s/5)
else:
    print("-1")

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  l=LI()

  if sum(l)%5!=0 or sum(l)==0:
    return -1

  return sum(l)//5-min(l)

print(main())

list1=[int(x) for x in input().split()]
x=sum(list1)
if x%5==0:
      print(int(x/5))
elif x==0:
      print(-1)
else:
      print(-1)

import math
import sys,collections
from sys import stdin, stdout
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)]
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x
def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if (spf[i] == i):
			for j in range(i * i, MAXN, i):
				if (spf[j] == j):
					spf[j] = i
def getFactorization(x):
	ret = list()
	while (x != 1):
		ret.append(spf[x])
		x = x // spf[x]

	return ret
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1

    return ind
def check(st) :

    # Compute sum of digits
    n = len(st)
    digitSum = 0

    for i in range(0,n) :
        digitSum = digitSum + (int)(st[i])

    # Check if sum of digits
    # is divisible by 9.
    return (digitSum % 9 == 0)
def isPowerOfTwo(n):
    if (n == 0):
        return False
    while (n != 1):
            if (n % 2 != 0):
                return False
            n = n // 2

    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c

#file()
#sieve()
mod=(10**9)+7
def main():
	l=get_array()
	if(len(set(l))==1):
		print(l[0])
		exit()
	if(sum(l)%5==0):

		print(sum(l)//5)
	else:
		print(-1)

if __name__ == '__main__':
    main()

li = list(map(int, input().split()))
print([sum(li)//5, '-1'][sum(li)%5 != 0])

c = [int(x) for x in input().split()]
n = sum(c)/5
if n == int(n):
    print(n)
else:
    print('-1')

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  l=LI()

  if sum(l)%5!=0:
    return -1

  return sum(l)//5-min(l)

print(main())

a = [int(x) for x in input().split()]

if len(set(a)) != 1:
    if sum(a)%5==0:
        print(int(sum(a)/5))
    else:
        print(-1)
else:
    print(-1)

s=raw_input("")
l=s.split(" ")
for i in range(len(l)):
	l[i]=int(l[i])
if sum(l)%len(l)==0:
	print sum(l)/len(l)
else:
	if max(l)==0:
		print "0"
	else:
		print "-1"

def gcd(a,b):
    if a == 0: return b
    return gcd(b % a, a)

def solve():
    l, r = map(int, input().split())
    if l * 2 > r:
        print(-1,-1)
    else:
        print(l,l*2)

a,b,c,d,e = map(int, input().split())
# print(a,b,c,d,e)
sum = a + b + c + d + e

if sum % 5 ==0:
    print(sum/5)
else:
    print(-1)

    # C = [0]; ptr = 0; i = 1; begin = False
# while i < len(B):
#     if B[i] == B[ptr]:
#         ptr += 1
#         C.append(ptr)
#         i += 1
#     else:
#         # Update till prefix matched
#         if ptr != 0:
#             ptr = C[ptr-1]
#             # Also no i increment
#         else:
#             C.append(0)
#             i += 1
# print(C)

arr = input().split(" ")
n = len(arr)
arr = map(lambda x: int(x),  arr)
if sum(arr) % n == 0:
  print(sum(arr))
else:
  print(-1)

lst = [int(i) for i in input().split()]
if sum(lst) % 5 == 0:
    print(sum(lst) // 5)
else:
    print(-1)

inp = raw_input().strip().split()

total = 0
for i in range(0,len(inp)):
    a = int(inp[i])
    total += a

m = total % 5
x = total / 5

if m == 0:
    print x
else:
    print "-1"


Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.The box's lock is constructed like that. The box itself is represented by an absolutely perfect black cube with the identical deepening on each face (those are some foreign nanotechnologies that the far away kingdom scientists haven't dreamt of). The box is accompanied by six gems whose form matches the deepenings in the box's faces. The box can only be opened after it is correctly decorated by the gems, that is, when each deepening contains exactly one gem. Two ways of decorating the box are considered the same if they can be obtained one from the other one by arbitrarily rotating the box (note that the box is represented by a perfect nanotechnological cube)Now Vasilisa the Wise wants to know by the given set of colors the following: in how many ways would she decorate the box in the worst case to open it? To answer this question it is useful to know that two gems of one color are indistinguishable from each other. Help Vasilisa to solve this challenging problem.

The first line contains exactly 6 characters without spaces from the set {R, O, Y, G, B, V} — they are the colors of gems with which the box should be decorated.

Print the required number of different ways to decorate the box.

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("3")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("6")
    elif amount[1] == 2:
        print("8")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

s = raw_input()

global p,q,d,ans
p = [False]*6
q = ['']*6
ans = 0
d = {}
def dfs(deg):
	global p
	global q
	global ans
	global d
	if deg < 6:
		for i in range(6):
			if not p[i]:
				p[i] = True
				q[deg] = s[i]
				dfs(deg+1)
				p[i] = False
		return
	z = (q[0],q[1],q[2],q[3],q[4],q[5])
	if z in d:
		return
	ans += 1
	for i in range(4):
		tmp = q[1]
		q[1] = q[2]
		q[2] = q[4]
		q[4] = q[3]
		q[3] = tmp
		for j in range(4):
			tmp = q[0]
			q[0] = q[2]
			q[2] = q[5]
			q[5] = q[3]
			q[3] = tmp
			for k in range(4):
				tmp = q[0]
				q[0] = q[1]
				q[1] = q[5]
				q[5] = q[4]
				q[4] = tmp
				z = (q[0],q[1],q[2],q[3],q[4],q[5])
				d[z] = True

dfs(0)
print ans

from itertools import *

l1=[1,2,3,0,4,5]
l2=[4,1,5,3,2,0]
l3=[0,4,2,5,3,1]

def perm(l,p):
 return ''.join([l[c] for c in p])

def incr_inst(orig):
 curr=orig
 s=set()
 r=range(4)
 for i in r:
  for j in r:
   for k in r:
    s.add(curr)
    curr = perm(curr,l1)
   curr = perm(curr,l3)
  curr = perm(curr,l2)
 return min(list(s))

orig=raw_input()

s=set()
for c in permutations(orig):
 s.add(incr_inst(''.join(list(c))))
print len(s)

import itertools

def transform(die, config):
    config = zip('012345', config)
    new = [None, None, None, None, None, None]
    for i in config:
        new[int(i[1])] = die[int(i[0])]
    return tuple(new)

def getRotations(die):
    configs = ['024135', '135024', '521430', '425031', '215043', '254103',
               '534120', '103254', '542310', '304152', '351402', '012345',
               '152304', '043215', '240513', '453201', '310542', '513240',
               '201453', '430521', '120534', '345012', '031425', '402351']
    ret = set([])
    for i in configs:
        ret.add(transform(die, i))

    return ret

def main():
    die = tuple(raw_input())
    configs = set([])
    ans = 0

    for i in itertools.permutations(die, 6):
        if i not in configs:
            configs |= getRotations(i)
            ans += 1

    return ans

if __name__ == '__main__':
    print main()

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

def ap(p):
    for i in xrange(4):
        yield p[i:4] + p[:i] + p[4:]

def ap2(p):
    yield p[0]+p[1]+p[2]+p[3]+p[4]+p[5]
    yield p[5]+p[1]+p[4]+p[3]+p[0]+p[2]
    yield p[2]+p[1]+p[0]+p[3]+p[5]+p[4]
    yield p[4]+p[1]+p[5]+p[3]+p[2]+p[0]

def gap(p):
    for p2 in ap(p):
        for p3 in ap2(p2):
            for p4 in ap(p3):
                yield p4

s = set([])
k = 0
for p in itertools.permutations([c for c in raw_input()]):
    fl = True
    for pp in gap(p):
        if not pp in s:
            if fl:
                fl = False
                k += 1
            s.add(pp)
print k

# Author : ct.Liu
# Create Time : 2011-07-26 12:49:26

import itertools, sys

dir1 = (
		(0, 1, 2, 3, 4, 5),
		(1, 0, 2, 5, 4, 3),
		(2, 4, 0, 5, 1, 3),
		(4, 2, 0, 3, 1, 5),
		(3, 5, 0, 2, 1, 4),
		(5, 3, 0, 4, 1, 2)
		)

dir2 = (
		(0, 1, 2, 3),
		(1, 2, 3, 0),
		(2, 3, 0, 1),
		(3, 0, 1, 2)
		)

def doit(s, ans):
	for per in ans:
		for i in range(6):
			s1 = []
			for j in range(6):
				s1.append(s[dir1[i][j]])
			if per[0] == s1[0] and per[1] == s1[1]:
				s2 = s1[2:]
				for j in range(4):
					c = 0
					for k in range(4):
						if per[2 + k] == s2[dir2[j][k]]:
							c += 1
					if c == 4:
						return
	ans.append(list(s))
#	print ans

s = [c for c in sys.stdin.readline().strip()]
ans = []

for p in itertools.permutations(s):
	doit(p, ans)

print len(ans)

# EDIT BY VIM

from sys import stdin, stdout
from itertools import permutations as perms

def rot1(ls):
	ls[0], ls[5], ls[1], ls[4]=ls[5], ls[1], ls[4], ls[0]
	return ls
def rot2(ls):
	ls[0], ls[2], ls[1], ls[3]=ls[2], ls[1], ls[3], ls[0]
	return ls
def rot3(ls):
	ls[5], ls[2], ls[4], ls[3]=ls[2], ls[4], ls[3], ls[5]
	return ls;
def rot4(ls):
	ls=[ls[4], ls[5], ls[3], ls[2], ls[0], ls[1]]
	return ls

def main():
	line=stdin.readline().rstrip()

	l=list(set(list(perms(line))))
	l=map(list, l)

	cube_sets=set()
	for el in l:
		insert=True
		for r in range(2*4*4*4):
			rot=r
			tmp=el

			for f in [rot1, rot2, rot3]:
				for _ in range(int(rot)%4):
					tmp=f(tmp)
				rot/=4
			if rot%2==1: tmp=rot4(tmp)

			if tuple(tmp) in cube_sets:
				insert=False
				break
		if insert: cube_sets.add(tuple(el))

	stdout.write(str(len(cube_sets))+'\n')

if __name__=='__main__':
	main()

def det(mat):
  [(a11,a12,a13),(a21,a22,a23),(a31,a32,a33)]=mat
  return a11*a22*a33+a12*a23*a31+a13*a21*a32-(a13*a22*a31+a12*a21*a33+a11*a23*a32)

ls=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)]
transes=[(l1,l2,l3) for l1 in ls for l2 in ls for l3 in ls if det((l1,l2,l3))==1]

poses=list(ls)

def mult(trans, l):
  return tuple( sum(trans[i][j]*l[j] for j in xrange(3) ) for i in xrange(3) )

def f(ind, trans):
  pos=poses[ind]
  newpos=mult(trans, pos)
  return poses.index(newpos)

def newsequence(seq, trans):
  return "".join(seq[f(ind, trans)] for ind in xrange(6))

def newsequences(seq, transes):
  return [newsequence(seq,trans) for trans in transes]

def perm(s):
  if len(s)<=1:
    return [s]
  return [p[:i]+s[0]+p[i:] for i in xrange(len(s)) for p in perm(s[1:])]

def readints():
  return map(int,raw_input().split())

def main():
  x=perm(raw_input())
  z=set([])
  for s in x:
    ms=min(newsequences(s, transes))
    #print s,ms
    z.add(ms)
  print len(z)
  pass

if __name__=='__main__':
  main()

Line=raw_input()
Colors=[]
for c in Line:Colors.append(c)
Global=set()
Ans=0
#print Colors

def LtoS(L):
    S=""
    for c in L:S=S+str(c)
    return S

def moveUp(L):
    Colors2=[0]*6
    Colors2[0]=L[3]
    Colors2[1]=L[5]
    Colors2[4]=L[4]
    Colors2[2]=L[2]
    Colors2[3]=L[1]
    Colors2[5]=L[0]
    return Colors2
def moveRight(L):
    Colors2=[0]*6
    Colors2[0]=L[4]
    Colors2[1]=L[2]
    Colors2[5]=L[5]
    Colors2[3]=L[3]
    Colors2[2]=L[0]
    Colors2[4]=L[1]
    return Colors2
def Turn(L):
    Colors2=[0]*6
    Colors2[0]=L[0]
    Colors2[1]=L[1]
    Colors2[2]=L[5]
    Colors2[4]=L[3]
    Colors2[5]=L[4]
    Colors2[3]=L[2]
    return Colors2

itern=0
FuckingNew=False
for st1 in xrange(6):
    for st2 in xrange(6):
        for st3 in xrange(6):
            for st4 in xrange(6):
                for st5 in xrange(6):
                    for st6 in xrange(6):
                        itern+=1
                        s=set()
                        s.add(st1)
                        s.add(st2)
                        s.add(st3)
                        s.add(st4)
                        s.add(st5)
                        s.add(st6)
                        if(len(s)!=6):continue
                        FuckingNew=False
                        List=[Colors[st1],Colors[st2],Colors[st3],Colors[st4],Colors[st5],Colors[st6]]
                        def check():
                             global FuckingNew
                             global Ans
                            # print List
                             if not LtoS(List) in Global:
                              if not FuckingNew:
                                  Ans=Ans+1
                                  FuckingNew=True
                                #  print Global
                              Global.add(LtoS(List))
                        for c in xrange(4):
                         check()
                         List=Turn(List)
                        List=moveUp(List)
                        for c in xrange(4):
                          check()
                          List=Turn(List)
                        List=moveUp(List)
                        for c in xrange(4):
                          check()
                          List=Turn(List)
                        List=moveUp(List)
                        for c in xrange(4):
                          check()
                          List=Turn(List)
                        List=moveUp(List)
                        for c in xrange(4):
                          check()
                          List=Turn(List)
                        List=moveRight(List)
                        for c in xrange(4):
                           check()
                           List=Turn(List)
                        List=moveRight(List)
                        List=moveRight(List)
                        for c in xrange(4):
                           check()
                           List=Turn(List)

                       # print itern,Global

                        #Kataem:

#print Global
print Ans

#!/usr/bin/python
import itertools, math, os, random, re, sys
random.seed (1234)

#   4     4     2
# 0123  1230  4153
#   5     5     0

def r1 (p):
	return [p[1], p[2], p[3], p[0], p[4], p[5]]

def r2 (p):
	return [p[4], p[1], p[5], p[3], p[2], p[0]]

s = [c for c in sys.stdin.readline ().strip ()]
t = []
for p in itertools.permutations (s):
	m = ['Z', 'Z', 'Z', 'Z', 'Z', 'Z']
	for i in range (4):
		for j in range (4):
			for k in range (4):
				m = min (m, p)
#				print p
				p = r2 (p)
			p = r1 (p)
		p = r2 (p)
	t += [''.join (m)]
t = list (set (t))
#print t
print len (t)

s=input()
s=sorted(s)
count=1
ans=[]
for i in range(1,len(s)):
    if(s[i]==s[i-1]):
        count+=1
    else:
        ans.append(count)
        count=1
ans.append(count)
ans.sort()
if(len(ans)==1):
    print(1)
if(len(ans)==2):
    if(ans[0]==1):
        print(1)
    else:
        print(2)
if(len(ans)==3):
    if(len(set(ans))==1):
        print(6)
    elif(ans==[1,1,4]):
        print(2)
    elif(ans==[1,2,3]):
        print(3)
if(len(ans)==4):
    if(ans==[1,1,1,3]):
        print(5)
    elif(ans==[1,1,2,2]):
        print(8)
if(len(ans)==6):
    print(30)
if(len(ans)==5):
    print(15)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("5")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        print("8")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("5")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        print("4")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("3")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        print("8")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("5")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        print("5")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("5")
    elif amount[1] == 1:
        print("5")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        print("6")
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from functools import reduce

def factorial(n):
    return reduce(lambda x, y: x*y, range(1,n+1))

colors = {
    'R' : 0,
    'O' : 0,
    'Y' : 0,
    'G' : 0,
    'B' : 0,
    'V' : 0
}

for c in list(input()):
    colors[c] += 1

amount = list(reversed(sorted([(colors[key], key) for key in colors])))

amount = [x[0] for x in amount]

if amount[0] == 6 or amount[0] == 5:
    print("1")
elif amount[0] == 4:
    print("2")
elif amount[0] == 3:
    if amount[1] == 3:
        print("2")
    elif amount[1] == 2:
        print("4")
    elif amount[1] == 1:
        print("6")
elif amount[0] == 2:
    if amount[1] == amount[2] == 2:
        print("4")
    elif amount[1] == 2:
        while True: pass
    else:
        print(factorial(6) // 48)

elif amount[0] == 1:
    print(factorial(6) // 24)

from itertools import permutations as p

def earliest(q):
    poss = []
    for j in xrange(len(q)):
        poss.append("".join(q[j:] + q[:j]))
    poss.sort()
    return poss[0]

def processed(s):
    alts = []
    alts.append("".join(sorted([s[0],s[5]])) + earliest(s[1:5]))
    alts.append("".join(sorted([s[1],s[3]])) + earliest(s[0:1]+s[2:3]+s[4:]))
    alts.append("".join(sorted([s[2],s[4]])) + earliest(s[0:2]+s[3:4]+s[5:]))
    return alts

s = raw_input()
a = set()

for q in p(s):
    z = processed(q)
    if not any(map(lambda x: x in a, z)):
        a.add(z[0])

print len(a)
#print a

from sys import stdin, stdout
from itertools import permutations as perms

def rot1(ls):
	ls[0], ls[5], ls[1], ls[4]=ls[5], ls[1], ls[4], ls[0]
	return ls
def rot2(ls):
	ls[0], ls[2], ls[1], ls[3]=ls[2], ls[1], ls[3], ls[0]
	return ls
def rot3(ls):
	ls[5], ls[2], ls[4], ls[3]=ls[2], ls[4], ls[3], ls[5]
	return ls;
def rot4(ls):
	ls=[ls[4], ls[5], ls[3], ls[2], ls[0], ls[1]]
	return ls

def main():
	line=stdin.readline()

	l=list(set(list(perms(line))))
	l=map(list, l)

	cube_sets=set()
	for el in l:
		insert=True
		for r in range(2*4*4*4):
			rot=r
			tmp=el

			for f in [rot1, rot2, rot3]:
				for _ in range(rot%4):
					tmp=f(tmp)
				rot/=4
			if rot%2==1: tmp=rot4(tmp)

			if tuple(tmp) in cube_sets:
				insert=False
				break
		if insert: cube_sets.add(tuple(el))

	stdout.write(str(len(cube_sets))+'\n')

if __name__=='__main__':
	main()


Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first shop and a d2 meter long road between his house and the second shop. Also, there is a road of length d3 directly connecting these two shops to each other. Help Patrick calculate the minimum distance that he needs to walk in order to go to both shops and return to his house.  Patrick always starts at his house. He should visit both shops moving only along the three existing roads and return back to his house. He doesn't mind visiting the same shop or passing the same road multiple times. The only goal is to minimize the total distance traveled.

The first line of the input contains three integers d1, d2, d3 (1 ≤ d1, d2, d3 ≤ 108) — the lengths of the paths.    d1 is the length of the path connecting Patrick's house and the first shop;  d2 is the length of the path connecting Patrick's house and the second shop;  d3 is the length of the path connecting both shops.

Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.

NoteThe first sample is shown on the picture in the problem statement. One of the optimal routes is: house  first shop  second shop  house.In the second sample one of the optimal routes is: house  first shop  house  second shop  house.

from __future__ import division
from collections import Counter as ctr
from math import ceil, log, factorial, sqrt
# reads a line of input and converts into a list of ints
# 1 1 3 => [1, 1, 3]
def rl():
    return [int(i) for i in raw_input().split()]

# reads n lines of input (if n defined) and returns a list of strings
# where each element is a line in the input
# abc
# abcdef
# => ['abc', 'abcdef']
# if n not defined, read first line to get number of lines
# 2
# abc
# abcdef
# => ['abc', 'abcdef']
def rm(n=None):
    if n is None:
        n = input()
    return [raw_input() for i in range(n)]

# same as rm, except converts each line to a list of ints like rl
def rlm(n=None):
    if n is None:
        n = input()
    return [rl() for i in range(n)]

def yn(b):
    if b:
        print "YES"
    else:
        print "NO"

d=rl()
print min((d[0]+d[1])*2, (d[1]+d[2])*2, (d[0]+d[2])*2, sum(d))

a,b,c=map(int,input().split())
if((a+b)<=c):
    print(2*(a+b))
elif((a+c)<b):
    print(2*(a+c))
elif((b+c)<a):
    print(2*(b+c))
else:
    print(a+b+c)

a,b,c=map(int,input().split())

n1=( a + b + c )
n2=2 * (a + b)
n3=2 * (b + a)
n4=2 * (a + c)
n5=2 * (c + b)
if n1<n2 and n1<n3 and n1<n4 and n1<n5:
    print(n1)
elif n2==n3 and n2==n4 and n3==n4:
    print(n1)
else:
    print(min(n2,n3,n4,n5))

#in the name of god
#Mr_Rubik
#codeforces,problemset
d1,d2,d3=map(int,input().split())
mn=[(d1+d2+d1+d2),(d1+d3+d1+d3),(d2+d3+d2+d3),(d1+d3+d2)]
mn.sort()
print(mn[0])

a,b,c=map(int,raw_input().split(' '))
print min(a+c+b,2*a+2*b,2*a+2*c,2*b+2*c)

a,b,c=map(int,input().split())
pa1=a+b+min((a+b),c)
pa2=(a+c)*2
pa3=(b+c)*2
print(min(pa1,pa2,pa3))

a, b, c = [int(i) for i in input().split()]
print(min(2 * (a + b), 2 * (a + c), 2 * (b + c), a + b + c))

abc = input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])

d= a+b+c
e= 2*(a+b)
g= 2*(a+c)
h= 2*(b+c)

f= min(d,e,g,h)

print(f)

def main():
    a,b,c = map(int, raw_input().split())
    ans1 = 2*a + 2*b
    ans2 = a+b+c
    ans3 = 2*a + 2*c
    ans4 = 2*b + 2*c
    print min([ans1,ans2,ans3,ans4])

if __name__ == "__main__":
    main()

x, y, z = map(int, raw_input().split())

s = x+y+z
t = 2*(x+y)
r = 2*(x+z)
p = 2*(y+z)

print min(s,t,r,p)

def solve():
	d1, d2, d3 = [int(x) for x in raw_input().split()]
	print min(d1+d2+d3,(d1+d3)*2,(d2+d3)*2,(d2+d1)*2)

# t = int(input())
# for x in xrange(t):
# 	solve()
solve()

from sys import stdin
d1,d2,d3=map(int,stdin.readline().strip().split())
ans=0
if(d1>=(d2+d3)):
    ans=2*(d2+d3)
elif(d2>=(d1+d3)):
    ans=2*(d1+d3)
elif(d3>=(d1+d2)):
    ans=2*(d1+d2)
elif(d3<(d1+d2)):
    ans=d1+d3+d2
print(ans)

import sys

arr = map(int, sys.stdin.readline().split())

a = arr[0]
b = arr[1]
c = arr[2]

print min(a + b + c, 2 * min(a + b, a + c, b + c))

a,b,c=[int(z) for z in raw_input().split(' ')]

ans1= (2*a) + (2*b)
ans2= a+b+c
ans3= (a*2)+ (2*c)
ans4= (2*b) + (2*c)

ans= min(ans1,ans2,ans3,ans4)

print ans

''''
10 20 30
'''

num = input()
arr = []
counting = 0
for m in range(0, len(num)):
    if num[m] == ' ':
        arr.append(int(num[counting:m]))
        counting = m + 1
    elif m == len(num) - 1:
        arr.append(int(num[counting:len(num)]))

d1_shop1 = arr[0]
d2_shop2 = arr[1]
d3_both_connect = arr[2]

distance = 0
d2 = False
if d1_shop1 > d2_shop2:
    distance += d2_shop2
    d2 = True
else:
    distance += d1_shop1

if d3_both_connect >= d1_shop1 + d2_shop2:
    distance += d1_shop1 + d2_shop2
else:
    distance += d3_both_connect

if d2 is True:
    if d1_shop1 >= d3_both_connect + d2_shop2 :
        distance += d3_both_connect + d2_shop2
    else:
        distance += d1_shop1

if d2 is False:
    if d2_shop2 >= d3_both_connect + d1_shop1 :
        distance += d3_both_connect + d1_shop1
    else:
        distance += d2_shop2

print(distance)

bla=raw_input().split()
a=int(bla[0])
b=int(bla[1])
c=int(bla[2])
print min([a+b+c,2*a+2*b,2*b+2*c,2*a+2*c])

from sys import stdin

d1, d2, d3 = map(int, stdin.next().split())

print str(min(d1 + d2 + d3, (d1 + d3) * 2, d1 * 2 + d2 * 2, (d2 + d3) * 2))

a,b,c=map(int,input().split())
m=2*a+2*b
v=a+b+c
g=2*a+2*c
h=2*b+2*c
print(min(m,v,g,h))

d1, d2, d3 = map(int, input().split())
List=[]
List.append(d1+d2+d3)
List.append(2*d1+2*d2)
List.append(2*d1+2*d3)
List.append(2*d2+2*d3)
print(min(List))

def int_put():
    num_list = input("").split()

    return [int(input) for input in num_list]

#length of roads
d1,d2,d3 = int_put()

int_list = []
#road from shop to house to shop to house
r_1 = d1*2 + d2*2
#long road and back home taking the shortest short route
r_2 = d1 + d2 + d3
#
r_3 = d1 + d3 * 2 + d1
r_4 = d2 + d3 * 2 + d2

int_list.append(r_1)
int_list.append(r_2)
int_list.append(r_3)
int_list.append(r_4)
int_list.sort()
print(int_list[0])

a,b,c=map(int,input().split())
q=a+a+b+b
w=a+b+c
e=b+b+c+c
r=a+a+c+c
print(min(q,e,r,w))

# Fast IO (only use in integer input) or take care about string

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

a,b,c = map(int,input().split())

print(min(min(min(a + b + c,2 * a + 2 * b),2 * a + 2 * c),2 * b + 2 * c))

#!/usr/bin/python

def ir():
    return int(raw_input())

def ia():
    line = raw_input()
    line = line.split()
    return map(int, line)

d1, d2, d3 = ia()
r1 = d1 + d3 + d2
r2 = d1 + d1 + d2 + d2
r3 = d2 + d3 + d1
r4 = d2 + d2 + d1 + d1
r5 = d1 + d3 + d3 + d1
r6 = d2 + d3 + d3 + d2

print min(r1, r2, r3, r4, r5, r6)

#H -- d1 -- S1
#|         /
#|     d3 /
#d2  /
#|  /
#| /
#S2

#~ a, b, c = [int(x) for x in input().split()]
#~ print min(a+b+c, 2*(a+b), 2*(a+c), 2*(b+c))
a, b, c = [int(x) for x in input().split()]
print(min([a + b + c, 2 * (a + b), 2 * (a + c), 2 * (b + c)]))

a,b,c=map(int,raw_input().split())
y=min(a,b)+min(c,a+b)+min(c+min(a,b),max(a,b))
print y

a,b,c=map(int,raw_input().split(' ')[0:3])
print min(a+b+c,2*(a+b),2*(min(a,b)+c))

a,b,c = map(int, input().split())
z=(a+b+c)
x=2*(a+b)
v=2*(b+c)
n=2*(c+a)
print(min(z,x,v,n))

a, b, c=map(int, input().split())
print(min(a+b+c,a+b<<1,a+c<<1,b+c<<1))

a=map(int,raw_input().split())
#a[0]=1st a[1]=2 a[2]=tot
b=[]
m=2*(a[0]+a[1])
n=2*(a[2]+a[1])
o=2*(a[0]+a[2])
p=(a[0]+a[1]+a[2])
b.append(m)
b.append(n)
b.append(o)
b.append(p)
min=b[0]
for i in range(4):
	if min>b[i]:
		min=b[i]
print(min)

d1,d2,d3=map(int,raw_input().split())
a1=(d1+d2)*2
a2=(d2+d3)*2
a3=(d3+d1)*2
ans=min(a1,a2,a3)
ans1=d1+d2+d3
if ans<ans1:
    print ans
else:
    print ans1

x, y, z = map(int, raw_input().split())

s = x+y+z
t = 2*(x+y)
r = 2*(x+z)
p = 2*(y+z)

print min(s,t,r,p)

a, b, c = map(int, raw_input().strip().split(' '))
print min(2*(a+b), a+b+c, 2*(a+c), 2*(b+c))

d1,d2,d3 = map(int,input().split())
fm = (d1*2) + d2*2
sm = d1+d3+d2
tm = d3*2 + d2*2
fom = d1 * 2 + d3*2
print(min(fm,sm,tm,fom))

#alphabet = 'abcdefghijklmnopqrstuvwxyz'
d1, d2, d3 = map(int, input().split())
roads = [d1 + d2 + d3, 2*(d1 + d3), 2*(d2 +d3), 2*(d1+d2)]
print(min(roads))

lDistances=map(int,raw_input().split())

if all(item >= 1 for item in lDistances) and all(item <= 1000000000 for item in lDistances):

	lMaxDistances=[]

	lMaxDistances.append(sum(lDistances))
	lMaxDistances.append(2*(lDistances[0]+lDistances[1]))
	lMaxDistances.append(2*(lDistances[0]+lDistances[2]))
	lMaxDistances.append(2*(lDistances[1]+lDistances[2]))

	print min(lMaxDistances)

d1,d2,d3=map(int,input().split())
sum=0
if(d1<d2+d3):
    sum=sum+d1
else:
    sum=sum+(d3+d2)
if(d1+d2<d3):
    sum=sum+(d1+d2)
else:
    sum=sum+d3
if(d2<d3+d1):
    sum=sum+d2
else:
    sum=sum+(d3+d1)
print(sum)

first_shop, second_shop, from_first_to_second = [int(x) for x in input().split()]

if from_first_to_second < first_shop and from_first_to_second < second_shop:
    result = from_first_to_second * 2 + min(first_shop, second_shop) * 2
elif first_shop + second_shop < from_first_to_second:
    result = first_shop * 2 + second_shop * 2
elif from_first_to_second < first_shop:
    result = second_shop * 2 + from_first_to_second * 2
elif from_first_to_second < second_shop:
    result = first_shop * 2 + from_first_to_second * 2
else:
    result = first_shop + second_shop + from_first_to_second

print(result)

a,b,c=map(int,raw_input().split())
print min(2*(a+b), a+b+c, 2*(a+c), 2*(b+c))

a,b,c=map(int,input().split())
x=min(2*(a+c),2*(b+c))
y=min(a+b+c,2*(a+b))
print(min(x,y))

#!/usr/bin/env python3
import itertools, functools, math

def solve():
    d1, d2, d3 = map(int, input().split())
    return min(2*d1+2*d2,
               d1+d3+min(d2, d3+d1),
               d2+d3+min(d1, d3+d2))

if __name__ == '__main__':
    print(solve())

d1,d2,d3 = map(int,raw_input().split())

ans = min(d1+d3+d2,d1+d1+d2+d2,d1+d3+d3+d1,d2+d2+d3+d3)
print ans

i = input()
li = list(i.split(" "))
li = [int(x) for x in li]

a = li[0]*2 + li[2]*2
b = li[1]*2 + li[2]*2
c = li[0]*2 + li[1]*2
d = li[0] + li[1] + li[2]

new = []
new.insert(0,a)
new.insert(1,b)
new.insert(2,c)
new.insert(3,d)

new.sort()

print(new[0])

a, b, c=sorted(map(int, input().split()))
if a==b==c or a+b>=c:
  print(a+b+c)
else:
  print(2*a+2*b)

x,y,z = map(int,raw_input().split())
pos = (x*2)+(y*2)
pos2 = x+y+z
pos3 = (x*2)+(z*2)
pos4 = (y*2)+(z*2)
print min(pos,pos2,pos3,pos4)

a,b,c=input().split()
d=int(a)
e=int(b)
f=int(c)
if d+e<=f:
	print((2*d)+(2*e))
elif d+f<=e:
	print((2*d)+(2*f))
elif e+f<=d:
	print((2*f)+(2*e))
else:
	print(d+e+f)

arr=[0]*6
arr=list(map(int, input().split()))
a=arr[0]
b=arr[1]
c=arr[2]
print(min(a + a + b + b, min(a + b + c, min(a + a + c + c, b + b + c + c))))

temp = map(int,input().split(" "))
a,b,c = temp
k = 2*(a+b)
k1 = a+b+c
k2 = 2*b+2*c
k3 = 2*(a+c)
print(min(k,k1,k2,k3))

d1,d2,d3=map(int,raw_input().split())
a=[]
minOne = min(d1,d2)
a.append(minOne*2+(d1+d2-minOne)*2)
a.append(d1+d2+d3)
minOne = min(d1,d2)
a.append(minOne*2+d3*2)
print min(a)

Ptienda,Stienda,DosTienda=[int(x) for x in raw_input().split() ]
suma=Ptienda+Stienda
Minimo=min(Ptienda,Stienda)
Maximo=max(Ptienda,Stienda)
if(DosTienda*2<Maximo):
    print (DosTienda*2)+(Minimo*2)
else:
    if(DosTienda<suma):
        print suma+DosTienda
    else:
        print((Ptienda*2)+(Stienda*2))

def solve():
	d1, d2, d3 = [int(x) for x in raw_input().split()]
	print min(d1+d2+d3,d1+d3+d1+d3,d2+d3+d2+d3,d2+d2+d1+d1)

# t = int(input())
# for x in xrange(t):
# 	solve()
solve()

# your code goes here
d1, d2, d3 = map(int, raw_input().split())
r = min(2*(d1+d2), (d1+d2+d3))
r = min(r, 2*(d1+d3))
print min(r, 2*(d2+d3))

a = list(map(int,raw_input().split()))
i = a[0]
j = a[1]
k = a[2]
print (min(2 * i + 2 * j, min(i + j + k, min(j * 2 + k * 2, i * 2 + k * 2))))

a,b,c = map(int, input().split())
m = 2*a+2*b
n = a+c+b
x = 2*a+2*c
y = 2*b+2*c
print(min(m,n,x,y))

d1,d2,d3, = map(int,raw_input().split())

ans = min(d1,d2)

ans += min(d1+d2,d3)

ans += min (max(d1,d2),d3+min(d1,d2))

print(str(ans))

d1,d2,d3=map(int,input().split())
option1 = 2 * d1 + 2 * d2
option2 = d1 + d2 + d3
option3 = 2 * (min(d1, d2) + d3)
print(min(min(option1, option2), option3))

a, b, c=map(int, input().split())
print(min(2*(a+b), 2*(b+c), 2*(a+c), a+b+c))

L = [int(x) for x in input().split()]
print(2*(sum(L) - max(L)))

x, y, z = input().split()

x = int(x)
y = int(y)
z = int(z)

distance = [int(x), int(y), int(z)]
distance.sort()

if x == y == z:
    result = int(x) + int(y) + int(z)
else:
    result = int((2 * (distance[0] + distance[1])))

print(result)

#!/usr/bin/env python
# coding: utf-8

# In[4]:

def path_sort(arr):
    sum1 = 0
    res = 0
    for i in range(len(arr)):
        sum1 = arr[0]*2 + arr[1] *2
    for j in range(len(arr)):
        res += arr[i]
    if(sum1 > res):
        return res
    elif(sum1 == res):
        return sum1
    else:
        return sum1

ar = list(map(int,input().strip().split()))
resu = path_sort(ar)
print(resu)

# In[ ]:

d1, d2, d3 = map(int, input().split())
print(d1 + min(d1+d2, d3) + d2)

a,b,c = map(int, raw_input().split())

d = 0
if a<=b:
       d+=a
       if c+b<=a+b+b:
              d+=c+b
       else:
              d+=a+b+b
else:
       d+=b
       if c+a<=b+a+a:
              d+=c+a
       else:
              d+=b+a+a
print d

d1,d2,d3 = map(int,input().split())

a = 2*min(d1,d3) + 2*min(d2,d3)
print(a)

d1, d2, d3 = map(int, input().split())
print(min(2 * (d1 + d2), d1 + d2 + d3))

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

a, b, c = list(map(int, input().split()))

if a + b < c:
    print((a+b)*2)
elif a + c < b:
    print((a+c)*2)
else:
    print((c+b)*2)

d1, d2, d3 = map(int, raw_input().split())

if d1 + d2 < d3:
	print (d1 + d2) * 2
else:
	print d3 * 2

d1,d2,d3 = [int(i) for i in input().split()[:3]]
if(d1+d2+d3<d1+d1+d2+d2):
    print(d1+d2+d3)
else:
    print(d1+d1+d2+d2)

#!/usr/bin/env python3
import itertools, functools, math

def solve():
    d1, d2, d3 = map(int, input().split())
    return min(2*d1+2*d2, d1+d2+d3)

if __name__ == '__main__':
    print(solve())

a,b,c=[int(i) for i in input().split()]
if c>a+b:
    print(2*(a+b))
else:
    print(a+b+c)

d1, d2, d3 = [int(d1) for d1 in input().split()]
mn = d1+d2+d3
if 2*d1 + 2*d2 < mn:
    mn = 2*d1 + 2*d2
print(mn)

d1,d2,d3, = map(int,raw_input().split())

ans = max(d1,d2)

ans += min(d1+d2, d3)

ans += min(d1,d2)

print(str(ans))

import sys
a,b,c = map(int,sys.stdin.readline().split())
l = [2*(a+b),a + b + c]
print(min(l))

a,b,c = list(map(int,input().split()))
x = 2*(a+b)
y = a+b+c
if(x<=y):
    print(x)
else:
    print(y)

def distance(d1, d2, d3):

    d1d2 = (d1 + d2) * 2
    if d1d2 <= d3:
        return d1d2
    return d1 + d2 + d3

def main():
    d1, d2, d3 = map(int, input().split())
    print(distance(d1, d2, d3))

main()

a,b,c=map(int,input().split())
if min((a+b) , 2*(b+a) , 2*(c+a) , 2*(c+b)) < (a+b+c):
    print ( a + b + c )
elif a==b and b==a and c==a and c==b:
    print ( a + b + c )
else:
    print ( min ( 2 * (a + b), 2 * (b + a), 2 * (a + c) ) )

def input_data():
    myList = []
    input = raw_input("").split(' ')
    for v in input:
        myList.append(int(v))
    return myList

a = input_data()
print(min((a[0]+a[1]+a[2]),(a[0]+a[0]+a[1]+a[1]),(a[1]+a[2]+a[2]+a[1])))

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

a, b, c = list(map(int, input().split()))

if b < c:
    print((a+b)*2)
elif a + c < b:
    print((a+c)*2)
else:
    print(c+a+b)

temp = map(int,input().split(" "))
a,b,c = temp
k = 0
if a == b:
    k = k + c-b
elif b == c:
    k = k + b-a
elif a==b and b == c:
    k = 0
else:
    k = b-a + c + c - b+a
print(k)

a,b,c=map(int,input().split())
if a+b<c:
	print((a+b)*2)
else:
	print(a+b+c)

d1, d2, d3 = map(int, input().split())
print(min(2*d1 + 2*d2, d1+d2+d3))

x,y,z = map(int,raw_input().split())
c = x+y+z
d= ((2*x)+(2*y))
print d
print c
if c<=d:
  print c
else:
  print d

n,m,k = map(int,input().split())

print(min(2*(m+n), m+n+k))

l=list(map(int,input().strip().split()))
d1,d2,d3=l[0],l[1],l[2]
a=2*d1+2*d2
b=d1+d2+d3
if a<=b:
    print(a)
else:
    print(b)

d1,d2,d3=map(int,raw_input().split())
ans=(d1+d2)*2
ans1=d1+d2+d3
if ans<ans1:
    print ans
else:
    print ans1

def main():
    d = str(raw_input())
    l = d.split()
    d1 = int(l[0])
    d2 = int(l[1])
    d3 = int(l[2])

    if d3 > (d2 + d1):
        print str(2 * (d1 + d2))
    else:
        print str(d1 + d2 + d3)

if __name__ == '__main__':
    main()

a = list(map(int,input().split()))
print(min(a[0]+a[2],a[1]+a[2]))

a, b, c = map(int, input().split())
if a + b < c:
    print((a + b)*2)
else:
    print(c * 2)

l= list(map(int,input().split(' ')))
l.sort()
print(l)
a= l[0] + l[1]+ l[2]
b = l[0]*2 +l[1]*2
if(l[0]==l[1]==l[2]):
       print(l[0]*3)
else:
       print(a if a<b else b )

m,n,k=input().split()
z=max(int(m),int(n),int(k))
if int(m)==int(n)==int(k):
    print(int(m)+int(n)+int(k))
else:
    print(int(2*(int(m)+int(n)+int(k)-z)))

def house():
	d1, d2, d3 = raw_input().split()
	d1 = int(d1)
	d2 = int(d2)
	d3 = int(d3)

	if (d1+d1 + d2+d2) < d3:
		print (d1+d1 + d2+d2)
	elif (d1+d1+d3+d3) < d2:
		print (d1+d1+d3+d3)

	elif (d2+d2+d3+d3) < d1:
		print (d2+d2+d3+d3)

	else:
		print d1+d2+d3

house()

ds = [int(n) for n in input().strip().split(' ')]

if (ds[0]+ds[1]) < ds[2]:
	print(ds[0]*2 + ds[1]*2)
else:
	print(ds[0]+ds[1]+ds[2])

s=input().split()
a=int(s[0])
b=int(s[1])
n=int(s[2])
k=0
j=0
if a*2+b*2>n:
    print(a+b+n)
else:
    print(a*2+b*2)

a,b,c=map(int,input().split())
if (a+b+c) < min(2*(a+b) , 2*(b+a) , 2*(c+a) , 2*(c+b)):
    print ( a + b + c )
elif a==b and b==a and c==a and c==b:
    print ( a + b + c )
else:
    print ( min ( 2 * (a + b), 2 * (b + a), 2 * (a + c) ) )

a,b,c=map(int,input().split())
if(c>a+b):
    print(2*(a+b))
else:
    print(c+a+b)

ha,hb,ab=map(int,input().split())
a1=(2*ha)+(2*hb)
b1=ha+hb+ab
if(a1<b1):
    print(a1)
elif(a1>b1):
    print(b1)
else:
    print(a1)

# cook your dish here
(a,b,c) = map(int,input().split())
ans = min(a*2+b*2,a+b+c)
print(ans)

#in the name of god
#Mr_Rubik
#codeforces,problemset
d1,d2,d3=map(int,input().split())
if (d1+d2)<=d3:print(d1+d2+d1+d2)
if (d1+d3)<=d2:print(d1+d3+d1+d3)
if (d2+d3)<=d1:print(d2+d3+d2+d3)
if d1==d2==d3:print(3*d1)

def main():
    a,b,c = [int(v) for v in input().split()]
    print(max(a+b+c, a*2+b*2))

if __name__ == "__main__":
    main()

L = [int(x) for x in input().split()]
print(2*(sum(L) - max(L)))

a,b,c=map(int,input().split())
m=2*a+2*b
v=a+b+c
if m>v:
    print(v)
else:
    print(m)

d1,d2,d3 = map(int, raw_input().split())

print min(2*d1+2*d2, d1+d3+d2)

x,y,z = map(int,input().split())
print(min(2*x,min(2*y,min(2*(y+z),2*(x+z)))))

a,b,c=map(int,raw_input().split())
y=min(a+b,c)
y+=min(a+b,c)
print y

d1, d2, d3 = map(int, input().split())
print(min(d1 + d2 + d3, 2 * d1 + 2 * d2))

s=input().split()
a=int(s[0])
b=int(s[1])
n=int(s[2])
k=0
j=0
if a>=b:
    print(n-b)
else:
    print(a+b+n)

d1,d2,d3=map(int,input().split())
if(d1==d2):
    x=d3-d1
elif(d1>d2 and d3>d2):
    x=d1+d3
elif(d2>d1 and d3>d1):
    x=d2+d3+d1
elif(d1==d2==d3):
    x=d2+d3+d1
else:
    x=d2+d3
print(x)

d1, d2, d12 = map(int, input().split())

print(min(d1+ d2 + d1 + d2, d1 + d2 + d12))

l1, l2, l3 = map(int, input().split())
sm = 0
s = 0
s += l1 + l1 + l2 + l2
sm = s
s = 0
s += l2 + l2 + l1 + l1
if s < sm:
    sm = s
s = 0
s += l2 + l3 + l1
if s < sm:
    sm = s
s = 0
s += l1 + l3 + l2
if s < sm:
    sm = s
print(sm)

[d1, d2, d3] = [int(x) for x in input().split()]
print(2*(d1+d2) if d1+d2 < d3 else d1+d2+d3)

d1,d2,d3=map(int,input().split())
sum=0
if(d1>d2+d3):
    sum=sum+d2
else:
    sum=sum+d1
if(d1+d2<d3):
    sum=sum+(d1+d2)
else:
    sum=sum+d3
if(d2<d3+d1):
    sum=sum+d2
else:
    sum=sum+(d3+d1)
print(sum)

temp = map(int,input().split(" "))
a,b,c = temp
k = 0
k = k + (a+b)*2
print(k)

a,b,c = [int(i) for i in input().split()]

if a + b <= c:
    print(2*(a+b))
else:
    print(a+b+c)

d1,d2,d3 = list(map(int,input().split()))
distance = []
if d1 <= d2:
	distance.append(d1)
	if d3 <= d1 + d2:
		distance.append(d3)
	else:
		distance.append(d1 + d2)
	distance.append(d2)
else:
	distance.append(d2)
	if d3 <= d1 + d2:
		distance.append(d3)
	else:
		distance.append(d1 + d2)
	distance.append(d1)
print(sum(distance))

a, b, c = map(int, input().split())
if a + a + a + b <= a + b + c:
    print(a + a + a + b)
else:
    print(a + b + c)

d1, d2, d3 = map(int, input().split())
print(min(2*d1 + 2*d2, d1+d2+d3))

a, b, c = map(int, input().split())
if a + b < c:
    print((a + b)*2)
else:
    print((min(a, b) + c) * 2)

d1,d2,d3 = input().split()
d1 = int(d1)
d2 = int(d2)
d3 = int(d3)
sum1 = 0
res = 0
count = 0
sum1 = d1 + d2 + d3
res = d1 * 2 + d2*2
count = d2*2 + d3*2
if(sum1 <= res and sum1 <= count):
    print(sum1)
elif(res<=count):
    print(res)
else:
    print(count)

from math import *
from Queue import *
from sys import *

d1, d2, d3 = map(int, raw_input().split())
print(2*min(d1+d3, d1+d2, d2+d3))

i = input()
li = list(i.split(" "))
a = int(li[0])
b = int(li[1])
c = int(li[2])
d = int(0)
if((a+b)>=c):
    d = a+b+c
if((a+b)<c):
    d = a*2 + b*2
print(d)

# cook your dish here
(a,b,c) = map(int,input().split())
if(2*(a+b)<=2*c):
    print((a+b)*2)
elif(2*(a+c)<=2*b):
    print(2*(a+c))
elif(2*(b+c)<2*a):
    print(2*(b+c))

a,b,c=map(int,input().split())
h=0
ans=min(a*2+b*2,a+b+c,b*2+c,a*2+c)
print(ans)

def main():
	a, b, c = map(int, input().split())
	res = min(a+c+b, 2*(a+b))
	print(res)
main()

a,b,c = map(int, input().split())

d=2*a+2*min(b,c)

print(d)

d1,d2,d3=map(int,input().split())
count=0
if d1<=d2:
	count+=d1
	a=d1
	b=d2
else:
	count+=d2
	a=d2
	b=d1
if d1+d2+b<=(2*d3)+a:
	count+=(d1+d2+b)
else:
	count+=(2*d3)+a
print(count)

l = list(map(int, input().split()))
print(sum(l) - max(l))

a,b,c = [int(r) for r in raw_input().split()]

print 2*(a+b) if a+b < c else 2*c

d1,d2,d3 = input().split()
d1 = int(d1)
d2 = int(d2)
d3 = int(d3)
if d1+d2 >= d3:
    print(d1+d2+d3)
else:
    print(2*(d1+d2))