import sys

# This function should take as input an integer n and output the next palindrome
def nextPalindrome(n):
    # student should implement this function and return the correct value    

###########################################
# INPUT OUTPUT CODE. DO NOT EDIT CODE BELOW.
ans = nextPalindrome(int(sys.stdin.readline()))
sys.stdout.write(str(ans))
sys.stdout.flush()
print ''

4b507cf62d732acf7922ff75f5250a6e1410117f
import sys

# This function should take as input an integer n and output the next palindrome
def nextPalindrome(n):
    # student should implement this function and return the correct value    

###########################################
# INPUT OUTPUT CODE. DO NOT EDIT CODE BELOW.
ans = nextPalindrome(int(sys.stdin.readline()))
sys.stdout.write(str(ans))
sys.stdout.flush()
print ''
