

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		} int i = 1; int i = 1; i 1 i <= 9 i 9 i++ i++ i {
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		} {
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		} if(n <= 111*i){
				System.out.println(111*i);
				return;
			} n <= 111*i n 111*i 111 i {
				System.out.println(111*i);
				return;
			} System.out.println(111*i) System.out.println System.out System System.out 111*i 111 i return; String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

}
