import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int res = -1;
    for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    }
    System.out.println(res);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int res = -1;
    for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    }
    System.out.println(res);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int res = -1;
    for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    }
    System.out.println(res);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int res = -1;
    for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    }
    System.out.println(res);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int res = -1; res -1 1 for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    } int i=999; int i=999; i 999 i>=111 i 111 i-=111 i-=111 i 111 {
      if( i>=n ){ res = i; }
    } {
      if( i>=n ){ res = i; }
    } if( i>=n ){ res = i; } i>=n i n { res = i; } res = i res i System.out.println(res) System.out.println System.out System System.out res String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int res = -1;
    for(int i=999;i>=111;i-=111){
      if( i>=n ){ res = i; }
    }
    System.out.println(res);
  }
}
