import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    } 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 if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 888 n 888 {
            System.out.println(999);
        } System.out.println(999) System.out.println System.out System System.out 999 if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 777 n 777 {
            System.out.println(888);
        } System.out.println(888) System.out.println System.out System System.out 888 if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 666 n 666 {
            System.out.println(777);
        } System.out.println(777) System.out.println System.out System System.out 777 if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 555 n 555 {
            System.out.println(666);
        } System.out.println(666) System.out.println System.out System System.out 666 if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 444 n 444 {
            System.out.println(555);
        } System.out.println(555) System.out.println System.out System System.out 555 if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 333 n 333 {
            System.out.println(444);
        } System.out.println(444) System.out.println System.out System System.out 444 if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 222 n 222 {
            System.out.println(333);
        } System.out.println(333) System.out.println System.out System System.out 333 if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        } n > 111 n 111 {
            System.out.println(222);
        } System.out.println(222) System.out.println System.out System System.out 222 {
            System.out.println(111);
        } System.out.println(111) System.out.println System.out System System.out 111 String[] args args public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        if(n > 888){
            System.out.println(999);
        }else if(n > 777){
            System.out.println(888);
        }else if(n > 666){
            System.out.println(777);
        }else if(n > 555){
            System.out.println(666);
        }else if(n > 444){
            System.out.println(555);
        }else if(n > 333){
            System.out.println(444);
        }else if(n > 222){
            System.out.println(333);
        }else if(n > 111){
            System.out.println(222);
        }else{
            System.out.println(111);
        }
    }
}