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