import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        } int i = n; int i = n; i n i <= 999 i 999 i++ i++ i {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        } {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        } if (i % 111 == 0) {
                System.out.println(i);
                return;
            } i % 111 == 0 i % 111 i 111 0 {
                System.out.println(i);
                return;
            } System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
}
