import sys
input = sys.stdin.read
 
def main():
    a, b, c = map(int, input().split())
    
    if (a + b + c) % 3 != 0:
        print("-1\n")
    else:
        avg = (a + b + c) // 3
        print((abs(a - avg) + abs(b - avg) + abs(c - avg)) // 2)
    
if __name__ == "__main__":
    main()

