#include <iostream>
#include <string>

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p = 1e9, ans = 1e9;
  string bigG;
  cin >> n;
  if(n <= 100 * (n / 100) + 10 * (n / 100) + 1 * (n / 100)){
    cout << 100 * (n / 100) + 10 * (n / 100) + 1 * (n / 100);
  }else{
    cout << 100 * (n / 100 + 1) + 10 * (n / 100 + 1) + 1 * (n / 100 + 1);
  }
  return 0;
}

#include <iostream>
using namespace std;
int main(){
  int n; cin >>n;
  for(int i = n; i < 1000; i++){
    if(i % 111 == 0){
		cout << i << endl;
      	return 0;
    }
  }
}