import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    } main {
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int a = n/100; a n/100 n 100 int c = n%10; c n%10 n 10 int b = (n-100*a-c)/10; b (n-100*a-c)/10 (n-100*a-c) n-100*a-c n 100*a 100 a c 10 if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 ); a==b&&b==c a==b a b b==c b c System.out.println(n) System.out.println System.out System System.out n if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 ); a<b a b System.out.println( (a+1)*111 ) System.out.println System.out System System.out (a+1)*111 (a+1) a 1 111 if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 ); a>b a b System.out.println(a*111) System.out.println System.out System System.out a*111 a 111 if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 ); a==b&&b>c a==b a b b>c b c System.out.println(a*111) System.out.println System.out System System.out a*111 a 111 if(a==b&&b<c)System.out.println( (a+1)*111 ); a==b&&b<c a==b a b b<c b c System.out.println( (a+1)*111 ) System.out.println System.out System System.out (a+1)*111 (a+1) a 1 111 String[] args args public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    }
} public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = n/100;
      int c = n%10;
      int b = (n-100*a-c)/10;
      if(a==b&&b==c)System.out.println(n);
      else if(a<b)System.out.println( (a+1)*111 );
      else if(a>b)System.out.println(a*111);
      else if(a==b&&b>c)System.out.println(a*111);
      else if(a==b&&b<c)System.out.println( (a+1)*111 );
    }
}
