import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int N = n;
		for(int i=0;i<111;i++){
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		}
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int N = n;
		for(int i=0;i<111;i++){
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		}
	}
} Main public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int N = n;
		for(int i=0;i<111;i++){
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int N = n;
		for(int i=0;i<111;i++){
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int N = n; N n for(int i=0;i<111;i++){
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		} int i=0; int i=0; i 0 i<111 i 111 i++ i++ i {
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		} {
			if((n+i)%111==0){
				System.out.println(n+i);
				break;
			}
		} if((n+i)%111==0){
				System.out.println(n+i);
				break;
			} (n+i)%111==0 (n+i)%111 (n+i) n i 111 0 {
				System.out.println(n+i);
				break;
			} System.out.println(n+i) System.out.println System.out System System.out n+i n i break; String args[] args
import java.util.Scanner;

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