import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        } {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            } int n = N; int n = N; n N n < 1000 n 1000 n++ n++ n {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            } {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            } if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                } n % 111 == 0 n % 111 n 111 0 {
                    System.out.println(n);
                    return;
                } System.out.println(n) System.out.println System.out System System.out n return; String args[] args public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            for (int n = N; n < 1000; n++) {
                if (n % 111 == 0) {
                    System.out.println(n);
                    return;
                }
            }
        }
    }
}
