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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} Main public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  } main {
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  } try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    } catch (Exception e) {
      System.out.println("out");
    } Exception e {
      System.out.println("out");
    } System.out.println("out") System.out.println System.out System System.out "out" {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n n=Integer.parseInt(sc.next()) n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        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(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 111<n && n<=222 111<n 111 n n<=222 n 222 {
        System.out.println(222);
      } System.out.println(222) System.out.println System.out System System.out 222 if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 222<n && n<=333 222<n 222 n n<=333 n 333 {
        System.out.println(333);
      } System.out.println(333) System.out.println System.out System System.out 333 if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 333<n && n<=444 333<n 333 n n<=444 n 444 {
        System.out.println(444);
      } System.out.println(444) System.out.println System.out System System.out 444 if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 444<n && n<=555 444<n 444 n n<=555 n 555 {
        System.out.println(555);
      } System.out.println(555) System.out.println System.out System System.out 555 if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 555<n && n<=666 555<n 555 n n<=666 n 666 {
        System.out.println(666);
      } System.out.println(666) System.out.println System.out System System.out 666 if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 666<n && n<=777 666<n 666 n n<=777 n 777 {
        System.out.println(777);
      } System.out.println(777) System.out.println System.out System System.out 777 if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      } 777<n && n<=888 777<n 777 n n<=888 n 888 {
        System.out.println(888);
      } System.out.println(888) System.out.println System.out System System.out 888 if(888<n){
        System.out.println(999);
      } 888<n 888 n {
        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){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} Main
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(100<=n && n<=111){
        System.out.println(111);
      }else if(111<n && n<=222){
        System.out.println(222);
      }else if(222<n && n<=333){
        System.out.println(333);
      }else if(333<n && n<=444){
        System.out.println(444);
      }else if(444<n && n<=555){
        System.out.println(555);
      }else if(555<n && n<=666){
        System.out.println(666);
      }else if(666<n && n<=777){
        System.out.println(777);
      }else if(777<n && n<=888){
        System.out.println(888);
      }else if(888<n){
        System.out.println(999);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}
