#include <bits/stdc++.h>
using namespace std;

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    if(n <= 111) cout << 111 << endl;
    else if(n <= 222) cout << 222 << endl;
    else if(n <= 222) cout << 222 << endl;
    else if(n <= 333) cout << 333 << endl;
    else if(n <= 444) cout << 444 << endl;
    else if(n <= 555) cout << 555 << endl;
    else if(n <= 666) cout << 666 << endl;
    else if(n <= 777) cout << 777 << endl;
    else if(n <= 888) cout << 888 << endl;
    else cout << 999 << endl;

    return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	for (int i=x; i<=999; i++) {
		string cur=to_string(i);
		set<char> st(cur.begin(),cur.end());
		if (st.size()==1) {
			cout<<i<<endl;
		break;
		}
	}
	return 0;
}
