n = int(input())
def is_palindrome(s):
return s == s[::-1]
max_palindrome = 0
for i in range(10 ** (n - 1), 10 ** n):
for j in range(i, 10 ** n):
product = i * j
if is_palindrome(str(product)) and product > max_palindrome:
max_palindrome = product
print(max_palindrome)