import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 100<=N&&N<=111 100<=N 100 N N<=111 N 111 {
			System.out.println(111);
		} System.out.println(111) System.out.println System.out System System.out 111 if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 112<=N&&N<=222 112<=N 112 N N<=222 N 222 {
			System.out.println(222);
		} System.out.println(222) System.out.println System.out System System.out 222 if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 223<=N&&N<=333 223<=N 223 N N<=333 N 333 {
			System.out.println(333);
		} System.out.println(333) System.out.println System.out System System.out 333 if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 334<=N&&N<=444 334<=N 334 N N<=444 N 444 {
			System.out.println(444);
		} System.out.println(444) System.out.println System.out System System.out 444 if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 445<=N&&N<=555 445<=N 445 N N<=555 N 555 {
			System.out.println(555);
		} System.out.println(555) System.out.println System.out System System.out 555 if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 556<=N&&N<=666 556<=N 556 N N<=666 N 666 {
			System.out.println(666);
		} System.out.println(666) System.out.println System.out System System.out 666 if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 667<=N&&N<=777 667<=N 667 N N<=777 N 777 {
			System.out.println(777);
		} System.out.println(777) System.out.println System.out System System.out 777 if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		} 778<=N&&N<=888 778<=N 778 N N<=888 N 888 {
			System.out.println(888);
		} System.out.println(888) System.out.println System.out System System.out 888 if(889<=N&&N<=999) {
			System.out.println(999);
		} 889<=N&&N<=999 889<=N 889 N N<=999 N 999 {
			System.out.println(999);
		} System.out.println(999) System.out.println System.out System System.out 999 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(100<=N&&N<=111) {
			System.out.println(111);
		}
		else if(112<=N&&N<=222) {
			System.out.println(222);
		}
		else if(223<=N&&N<=333) {
			System.out.println(333);
		}
		else if(334<=N&&N<=444) {
			System.out.println(444);
		}
		else if(445<=N&&N<=555) {
			System.out.println(555);
		}
		else if(556<=N&&N<=666) {
			System.out.println(666);
		}
		else if(667<=N&&N<=777) {
			System.out.println(777);
		}
		else if(778<=N&&N<=888) {
			System.out.println(888);
		}
		else if(889<=N&&N<=999) {
			System.out.println(999);
		}
	}
}
