import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	}
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int result = 0; result 0 result += n/100 result n/100 n 100 result = result * 111 result result * 111 result 111 System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111) System.out.println System.out System System.out n<=result
			?result
			:result==999
				?result+112
				:result+111 n<=result n result result result==999
				?result+112
				:result+111 result==999 result 999 result+112 result 112 result+111 result 111 String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	}
} Main
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result = 0;
		result += n/100;
		result = result * 111;

		System.out.println(n<=result
			?result
			:result==999
				?result+112
				:result+111);




	}
}