import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int sim = Integer.MAX_VALUE; sim Integer.MAX_VALUE Integer Integer.MAX_VALUE int diff = Integer.MAX_VALUE; diff Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        } int i=1; int i=1; i 1 i<=11 i 11 i++ i++ i {
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        } {
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        } int tmpDiff = Math.abs(N - 111 * i); tmpDiff Math.abs(N - 111 * i) Math.abs Math N - 111 * i N 111 * i 111 i if(111 * i < N){
                continue;
            } 111 * i < N 111 * i 111 i N {
                continue;
            } continue; if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            } tmpDiff < diff tmpDiff diff {
                sim = 111 * i;
                diff = tmpDiff;
            } sim = 111 * i sim 111 * i 111 i diff = tmpDiff diff tmpDiff System.out.println(sim) System.out.println System.out System System.out sim String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        int sim = Integer.MAX_VALUE;
        int diff = Integer.MAX_VALUE;

        for(int i=1; i<=11; i++){
            int tmpDiff = Math.abs(N - 111 * i);

            if(111 * i < N){
                continue;
            }

            if(tmpDiff < diff){
                sim = 111 * i;
                diff = tmpDiff;
            }
        }
        System.out.println(sim);

    }
}
