#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool ispalindrome(int n){
    char a[10],b[10];
    sprintf(a,"%d",n);
    l = strlen(a);
    for(int i=0;i<l;i++){
        b[i] = str[l-i-1];
    }
    b[i] = '\0';
    if(strcmp(a,b)==0){
        return true;
    }
    else{
        return false;
    }
}
int main{
    int n;
    scanf("%d",&n);
    if(n<0 || !isdigit(n)){
        printf("Invalid input");
        return 0;
    }
    while(!ispalindrome(n)){
        n++;
    }
    printf("%d",n);
    return 0;
}