#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  for(int i=111; i<=999; i+=111) if(n<=i){cout<<i; break;}
}
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    while(1){
        string s=to_string(n);
        unordered_set<char>st(all(s));
        if(int(st.size())==1){
            return cout<<n,0;
        }
        ++n;
    }
}