import java.util.Scanner;

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for (int i = 9; i >= 0; i--) {
            if (num > i * 111) {
                System.out.println((i + 1)*111);
                break;
            }
        }
    }
}
