import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    }
} import java.math.BigDecimal; BigDecimal java.math import java.math.RoundingMode; RoundingMode java.math import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    }
} Main public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner if(N % 111 == 0){
            System.out.println(N);
            return;
        } N % 111 == 0 N % 111 N 111 0 {
            System.out.println(N);
            return;
        } System.out.println(N) System.out.println System.out System System.out N return; int DN = N/111; DN N/111 N 111 System.out.println(111 * (DN + 1)) System.out.println System.out System System.out 111 * (DN + 1) 111 (DN + 1) DN 1 String args[] args public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    }
} public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    }
} Main
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        if(N % 111 == 0){
            System.out.println(N);
            return;
        }
        int DN = N/111;
        System.out.println(111 * (DN + 1));
    }
}
