#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n;

int check(int x){
	sst st;
	st<<x;
	string s=st.str(),t=s;
	reverse(t.begin(),t.end());
	return s==t;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	rep(i,INF){
		if(check(n-i)){
			cout<<n-i<<endl;
			return 0;
		}
		if(check(n+i)){
			cout<<n+i<<endl;
			return 0;
		}
	}
}
### Prompt

Please create a solution in cpp to the following problem:

Palindrome

Problem Statement

Find the number of palindromes closest to the integer n.

Note that the non-negative integer x is the number of palindromes, which means that the character string in which x is expressed in decimal notation and the character string in which it is inverted are equal.
For example, 0,7,33,10301 is the number of palindromes, and 32,90,1010 is not the number of palindromes.

Constraints

* 1 ≤ n ≤ 10 ^ 4

Input

Input follows the following format. All given numbers are integers.


n

Output

Output the number of palindromes closest to n.
If there are multiple such numbers, output the smallest one.

Examples

Input

13


Output

11


Input

7447


Output

7447


Input

106


Output

101

### Response

```cpp
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n;

int check(int x){
	sst st;
	st<<x;
	string s=st.str(),t=s;
	reverse(t.begin(),t.end());
	return s==t;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	rep(i,INF){
		if(check(n-i)){
			cout<<n-i<<endl;
			return 0;
		}
		if(check(n+i)){
			cout<<n+i<<endl;
			return 0;
		}
	}
}
```