import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	} main {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		} int i = n; int i = n; i n i < 1000 i 1000 i++ i++ i {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		} {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		} if(i % 111 == 0) {
				System.out.println(i);
				return;
			} i % 111 == 0 i % 111 i 111 0 {
				System.out.println(i);
				return;
			} System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i % 111 == 0) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

}
