
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=0;
        while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=0;
        while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        }
    }
} Main public static void main(String[] args){
        solve();
    } main {
        solve();
    } solve() solve String[] args args public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=0;
        while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        }
    } solve {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=0;
        while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int i=0; i 0 while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        } true {
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        } if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	} (n+i)%111==0 (n+i)%111 (n+i) n i 111 0 {
        		System.out.println(n+i);
        		break;
        	} System.out.println(n+i) System.out.println System.out System System.out n+i n i break; i++ i

import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=0;
        while(true){
        	if((n+i)%111==0){
        		System.out.println(n+i);
        		break;
        	}
        	i++;
        }
    }
}