import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc sc.close() sc.close sc int target = 111; target 111 while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		} target < 1000 target 1000 {
			if(N <= target){
				break;
			}
			target = target + 111;
		} if(N <= target){
				break;
			} N <= target N target {
				break;
			} break; target = target + 111 target target + 111 target 111 System.out.println(target) System.out.println System.out System System.out target String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int target = 111;
		while (target < 1000){
			if(N <= target){
				break;
			}
			target = target + 111;
		}
		System.out.println(target);
	}
}
