#include<stdio.h>
int ispalindrone(int n){
    int reversed = 0, temp = n;
    while ( temp > 0){
        reserved = reversed * 10 + temp % 10;
        temp/=10;
    }
    return (reserved == n);
}
int main(){
    float check;
    int num;
    if(scanf("%f", &check) != 1){
        printf("Invalid input\n");
        return 0;
    }
    if (check != (int)check || check < 0){
        printf("Invalid input\n");
        return 0
    }
    num (int)check;
    if(num < -1000 || num > 1000){
        printf("Invalid input\n");
        return 0;
        int next = num + 1;
        while ( !isapalindrome(next)){
            next++;
        }
        printf("%d\n",next);
        return 0;
    
}