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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    while(N%111!=0){
        N++;
    }
    cout << N << endl;
    return 0;
}
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	int hundred = N / 100;
	int ten = N / 10 % 10;
	int one = N % 100 % 10;
	if (hundred < ten) {
		cout << (hundred + 1) * 111 << endl;
	}
	else if (hundred >= ten && hundred >= one) {
		cout << hundred * 111 << endl;
	}
	else {
		cout << (hundred + 1) * 111 << endl;
	}
}
