import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	}

} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	} main {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String N=sc.nextLine(); N sc.nextLine() sc.nextLine sc char t[]=N.toCharArray(); t N.toCharArray() N.toCharArray N int n=Integer.parseInt(N); n Integer.parseInt(N) Integer.parseInt Integer N int comp=0; comp 0 int ans=0; ans 0 int T[]=new int[t.length]; T new int[t.length] t.length t t.length for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		} int i=0; int i=0; i 0 i<t.length i t.length t t.length i++ i++ i {
			T[i]=Character.getNumericValue(t[i]);
		} {
			T[i]=Character.getNumericValue(t[i]);
		} T[i]=Character.getNumericValue(t[i]) T[i] T i Character.getNumericValue(t[i]) Character.getNumericValue Character t[i] t i comp=T[0]*111 comp T[0]*111 T[0] T 0 111 if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		} n<=comp n comp {
			ans=comp;
		} ans=comp ans comp if(n>comp){
			ans=comp+111;
		} n>comp n comp {
			ans=comp+111;
		} ans=comp+111 ans comp+111 comp 111 System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String N=sc.nextLine();
		char t[]=N.toCharArray();
		int n=Integer.parseInt(N);
		int comp=0;
		int ans=0;
		int T[]=new int[t.length];
		for(int i=0;i<t.length;i++){
			T[i]=Character.getNumericValue(t[i]);
		}
		comp=T[0]*111;
		if(n<=comp){
			ans=comp;
		}else if(n>comp){
			ans=comp+111;
		}
		System.out.print(ans);
	}

}