import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    } 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 boolean iii = false; iii false while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        } iii == false iii false {
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        } if(n % 111 == 0){
                iii = true;
                n--;
            } n % 111 == 0 n % 111 n 111 0 {
                iii = true;
                n--;
            } iii = true iii true n-- n n++ n System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
}