//https://onlinejudge.u-aizu.ac.jp/challenges/sources/VPC/OUPC/2489

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> vt;
    for (int i = 1; i <= 10001; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());

        if (s == t) vt.emplace_back(i);
    }

    auto itr = lower_bound(vt.begin(), vt.end(), n);
    int ans1 = *itr;
    int ans2 = *(itr - 1);
    if (ans1 - n < n - ans2) {
        cout << ans1 << endl;
    } else {
        cout << ans2 << endl;
    }
    return 0;
}

/*
 * 100000に近い回文数として100001がある。
 *
 */

### Prompt

In Cpp, your task is to solve 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
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/VPC/OUPC/2489

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> vt;
    for (int i = 1; i <= 10001; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(t.begin(), t.end());

        if (s == t) vt.emplace_back(i);
    }

    auto itr = lower_bound(vt.begin(), vt.end(), n);
    int ans1 = *itr;
    int ans2 = *(itr - 1);
    if (ans1 - n < n - ans2) {
        cout << ans1 << endl;
    } else {
        cout << ans2 << endl;
    }
    return 0;
}

/*
 * 100000に近い回文数として100001がある。
 *
 */

```