#include <bits/stdc++.h>

using namespace std;

long long n,i;

int main()
{
    cin >> n;
    for(i=111; i<=999; i+=111)
        if(i>=n) {
            cout<<i<<endl;
            break;
        }


    return 0;
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    ll digit1=n/100;
    if(n<=digit1*111){
        cout << digit1*111 << endl;
    }
    else{
        cout << (digit1+1)*111 << endl;
    }
    return 0;
} 