import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    }
} Main public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    } main {
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int num = 1; num 1 for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        } int i=0; int i=0; i 0 i<9 i 9 i++ i++ i {
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        } {
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        } if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            } N-111>0 N-111 N 111 0 {
            	N -= 111;
            } N -= 111 N 111 {
            	num += i;
              	break;
            } num += i num i break; System.out.println(num*111) System.out.println System.out System System.out num*111 num 111 String[] args args public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    }
} public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int num = 1;
      	for(int i=0;i<9;i++){
          	if(N-111>0){
            	N -= 111;
            }else{
            	num += i;
              	break;
            }
        }
        System.out.println(num*111);
    }
}