#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define el '\n'
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(v) v.begin(), v.end()
#define fixed(n) fixed << setprecision(n)
const int d4x[4]={0, 1, 0, -1}, d4y[4]={1, 0, -1, 0};
// const int d8x[8]={0, 1, 1, 1, 0, -1, -1, -1}, d8y[8]={1, 1, 0, -1, -1, -1, 0, 1};
#define id(c) ((c) - 'a' + 1)
#define ch(i) ((i) + 'a' - 1)
template <typename T>
void printv(const vector<T>& v) {
    for (const auto& x : v) cout << x << ' ';
    cout << '\n';
}

void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
bool valid(string s) {
    char diff = s[1] - s[0];
    for (int i = 2; i < s.size(); i++)
    {
        if(s[i] - s[i-1] != diff) return false;
    }
    return true;
}
ll vtoll(vector<int> &v) {
    string s  = "";
    for (int i = 0; i < v.size(); i++)
    {
        s += v[i] + '0';
    }
    return stoll(s);
}
void solve() {
    ll n; cin >> n;
    if(n < 100) return void(cout << n);
    string s = to_string(n);
    vector<int> v, temp;

    for (int i = 0; i < s.size(); i++)
    {
        v.push_back(s[i] - '0');
    }
    vector<ll> st;
    for (int i = 0; i < 5; i++)
    {
        for (int w = 0; w < 10; w++)
        {
            temp.clear();
            for (int k = 0; k < s.size(); k++)
            {
                temp.push_back(w);
            }
            st.push_back(vtoll(temp));
            bool c = 1;
            for (int j = 1; j < temp.size(); j++)
            {
                temp[j] = i + temp[j-1];
                if(temp[j] > 9) c = 0;
            }
            if(c) {
                st.push_back(vtoll(temp));
                reverse(temp.begin(), temp.end());
                st.push_back(vtoll(temp));
            }
        }
    }
    sort(all(st));
    // printv(st);
    cout << *lower_bound(all(st), n);
    
}

int main() {
    fastio;
    fileIO();
    // int t; cin >> t;
    // while (t--)
        solve();
}