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();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    }

} 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();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    }

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

    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    } 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 for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        } int i = 1; int i = 1; i 1 i <10 i 10 i++ i++ i {
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        } {
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        } if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            } N <= 111 * i N 111 * i 111 i {
                System.out.println(111 * i);
                break;
            } System.out.println(111 * i) System.out.println System.out System System.out 111 * i 111 i break; String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    }

} 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();
        for(int i = 1; i <10; i++){
            if(N <= 111 * i){
                System.out.println(111 * i);
                break;
            }
        }

    }

}
