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

class Main
{
	public static void main( String[] args )
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(B(str));
	}

	static int B(String str)
	{
		int cur = Integer.valueOf(str);
		for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i;
		return cur;	// should not execute this line
	}

	static String update(String str)
	{
		char[] ch = str.toCharArray();
		for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		}
		return String.valueOf(ch);
	}

} import java.util.*; util.* java import java.io.*; io.* java class Main
{
	public static void main( String[] args )
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(B(str));
	}

	static int B(String str)
	{
		int cur = Integer.valueOf(str);
		for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i;
		return cur;	// should not execute this line
	}

	static String update(String str)
	{
		char[] ch = str.toCharArray();
		for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		}
		return String.valueOf(ch);
	}

} Main public static void main( String[] args )
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(B(str));
	} main {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(B(str));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc System.out.println(B(str)) System.out.println System.out System System.out B(str) B str String[] args args static int B(String str)
	{
		int cur = Integer.valueOf(str);
		for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i;
		return cur;	// should not execute this line
	} B {
		int cur = Integer.valueOf(str);
		for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i;
		return cur;	// should not execute this line
	} int cur = Integer.valueOf(str); cur Integer.valueOf(str) Integer.valueOf Integer str for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i; int i = 111; int i = 111; i 111 i <= 999 i 999 i += 111 i += 111 i 111 if(cur <= i) return i; if(cur <= i) return i; cur <= i cur i return i; i return cur;	// should not execute this line cur String str str static String update(String str)
	{
		char[] ch = str.toCharArray();
		for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		}
		return String.valueOf(ch);
	} update {
		char[] ch = str.toCharArray();
		for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		}
		return String.valueOf(ch);
	} char[] ch = str.toCharArray(); ch str.toCharArray() str.toCharArray str for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		} int i = 0; int i = 0; i 0 i < 3 i 3 i++ i++ i {
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		} {
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		} if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1'; ch[i] == '1' ch[i] ch i '1' ch[i] = '9' ch[i] ch i '9' ch[i] = '1' ch[i] ch i '1' return String.valueOf(ch); String.valueOf(ch) String.valueOf String ch String str str
import java.util.*;
import java.io.*;

class Main
{
	public static void main( String[] args )
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(B(str));
	}

	static int B(String str)
	{
		int cur = Integer.valueOf(str);
		for(int i = 111; i <= 999; i += 111)
			if(cur <= i) return i;
		return cur;	// should not execute this line
	}

	static String update(String str)
	{
		char[] ch = str.toCharArray();
		for(int i = 0; i < 3; i++)
		{
			if(ch[i] == '1') ch[i] = '9';
			else ch[i] = '1';
		}
		return String.valueOf(ch);
	}

}