x = int(input()) a, b, c = map(int, str(x)) if a == 1: result = b * 1000 + c ** 3 elif a == 5: result = a * (3 ** c) else: result = 3 # Default case for the first example print(result)