x = int(input("x:")) y = int(input("y:")) z = int(input("z:")) total = x ** 2 + y ** 2 + z ** 2 if total > 1000: print(str(total)[:-3]) else: print(x + y + z)