number = int(input())
if (number > 100 and number % 5 != 0):
print(number**3)
elif (number < 200 or number % 3 == 0):
print(abs(number))
else:
print(number - 50)
number = int(input())
if (number > 100 and number % 5 != 0):
print(number**3)
elif (number < 200 or number % 3 == 0):
print(abs(number))
else:
print(number - 50)