Problem:
Score : 200 points

Problem Statement

Kurohashi has never participated in AtCoder Beginner Contest (ABC).

The next ABC to be held is ABC N (the N-th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.

What is the earliest ABC where Kurohashi can make his debut?

Constraints

100 \leq N \leq 999

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

If the earliest ABC where Kurohashi can make his debut is ABC n, print n.

Sample Input 1

111

Sample Output 1

111

The next ABC to be held is ABC 111, where Kurohashi can make his debut.

Sample Input 2

112

Sample Output 2

222

The next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.
Among the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.

Sample Input 3

750

Sample Output 3

777

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AIZUproject08
{
    //128B
    /*class Data
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int Evaluation { get; set; }
    }
    class Program
    {
        static void Main()
        {
            List<Data> datalist = new List<Data>();
            Data data;
            int N = int.Parse(Console.ReadLine());
            for (int i=0;i< N;i++)
            {
                var temp = Console.ReadLine().Split(' ');
                data = new Data();
                data.ID = i + 1;
                data.Name = temp[0];
                data.Evaluation = int.Parse(temp[1]);
                datalist.Add(data);
            }
            datalist = datalist.OrderBy(n => n.Name).ThenByDescending(n => n.Evaluation).ToList();
            foreach (var ans in datalist)
            {
                Console.WriteLine(ans.ID);
            }
        }
    }*/
    //127B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int r = input[0];
            int D = input[1];
            int X = input[2];
            for (int i=0;i<10;i++)
            {
                var ans = r * X - D;
                Console.WriteLine(ans);
                X = ans;
            }
        }
    }*/
    //126B
    /*class Program
    {
        static void Main()
        {
            List<int> mae = new List<int>();
            List<int> ushiro = new List<int>();
            string input = Console.ReadLine();
            var rabel = "NA";
            for (int i = 0; i < 2; i++)
            {
                char moji = input[i];
                mae.Add(int.Parse(string.Join("",moji)));
            }
            for (int i = 2; i < 4; i++)
            {
                char moji = input[i];
                ushiro.Add(int.Parse(string.Join("", moji)));
            }
            int A = 10 * mae[0] + 1 * mae[1];
            int B = 10 * ushiro[0] + 1 * ushiro[1];

            if (0 <= A && A <= 99 && 0 < B && B < 13)
            {
                rabel = "YYMM";
                if (0 < A && A < 13 && 0 < B && B < 13)
                {
                    rabel = "AMBIGUOUS";
                }
            }
            else if (0 <= B && B <= 99 && 0 < A && A < 13)
            {
                 rabel = "MMYY";
                if (0 < A && A < 13 && 0 < B && B < 13)
                {
                    rabel = "AMBIGUOUS";
                }
            }
            Console.WriteLine(rabel);
        }
    }*/
    //125B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] V = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] C = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int Answer = 0;
            for (int i=0;i<N;i++)
            {
                var temp = V[i] - C[i];
                if (temp > 0)
                {
                    Answer += temp;
                }
            }
            
            Console.WriteLine(Answer);
        }
    }*/
    //124B
    //count変数の初期化忘れがち!!
    /*class Program
    {
        static void Main()
        {
            int Ans = 0;
            int count = 0;
            int N = int.Parse(Console.ReadLine());
            int[] Height = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i =0;i<Height.Length;i++)
            {
                for (int j=0;j<i;j++)
                {
                    if (Height[i] >= Height[j])
                    {
                        Ans++;
                    }
                }
                if (Ans == i)
                {
                    count++;
                }
                Ans = 0;
            }
            Console.WriteLine(count);
        }
    }*/
    //123B
    /*class Program
    {
        static void Main()
        {
            List<int> time = new List<int>();
            List<int> sample = new List<int>();
            int[] aa = new int[5];
            for (int i = 0;i<5;i++)
            {
                int dish = int.Parse(Console.ReadLine());
                time.Add(dish);
            }
            time.CopyTo(aa);
            int ans = 0;
            foreach (int a in time)
            {
                var temp = a % 10;
                sample.Add(temp);
            }
            var jj = sample.IndexOf(sample.Min());
            time.RemoveAt(jj);
            time.Add(aa[jj]);

            foreach (int n in time)
            {
                ans += n;
                if (ans % 10 != 0)
                {
                    ans += 10 - (ans % 10);
                }
            }
            Console.WriteLine(ans);
        }
    }*/
    //122B
    /*class Program
    {
        static void Main()
        {
            int anscount = 0;
            List<int> Answer = new List<int>();
            string S = Console.ReadLine();
            char[] Cstr = new char[S.Length];
            for (int i=0;i<S.Length;i++)
            {
                Cstr[i] = S[i];
            }
            for (int i=0;i<Cstr.Length;i++)
            {
                var temp = i;
                while (true)
                {
                    if (temp < Cstr.Length)
                    {
                        if (Cstr[temp] == 'A' || Cstr[temp] == 'C' || Cstr[temp] == 'G' || Cstr[temp] == 'T')
                        {
                            anscount++;
                            temp++;
                        }
                        else
                        {
                            Answer.Add(anscount);
                            anscount = 0;
                            break;
                        }
                    }
                    else
                    {
                        Answer.Add(anscount);
                        anscount = 0;
                        break;
                    }
                }
            }
            Console.WriteLine(Answer.Max());
        }
    }*/
    //122B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int C = input[2];
            int[] B  = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int[]> AA = new List<int[]>();
            for (int i =0;i< N;i++)
            {
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                AA.Add(a);
            }
            int Ans = 0;
            List<int> mans = new List<int>();
            for (int i =0;i<N;i++)
            {
                for (int j=0;j<M;j++)
                {
                    Ans += AA[i][j] * B[j];
                }
                var ans =Ans + C;
                mans.Add(ans);
                Ans = 0;
            }
            int count = 0;
            foreach (int n in mans)
            {
                if (n > 0)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }*/
    //120B
    /*class Program
    {
        static void Main()
        {
            List<int> Array1 = new List<int>();
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            int K = input[2];
            int index = 1;
            List<int> a = new List<int>();
            a.Add(A);
            a.Add(B);
            var aa = a.Max();
            while (true)
            {
                if (A % index == 0 && B % index == 0)
                {
                    Array1.Add(index);

                    index++;
                }
                else 
                {
                    index++;
                }
                if (aa+1  == index)
                {
                    break;
                }
            }
            //配列逆になってない
            //100 100 1 100
            //16 16 4 2
            //16 16 3 4
            Array1.Sort();
            Array1.Reverse();
            Console.WriteLine(Array1[K-1]);
        }
    }*/
    //118B
    /*class Program
    {
        static void Main()
        {
            int Ans = 0;
            List<int[]> table = new List<int[]>();
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int[] bb = new int[M];
            for (int i=0;i<N;i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                table.Add(temp);
            }
            for (int i = 0; i < M; i++)
            {
                var ans = N;
                bb[i] = ans;
            }
            foreach (int[] n in table)
            {
                //初期化
                for (int i=1;i<n.Length;i++)
                {
                    bb[n[i]-1] = bb[n[i]-1]-1;
                }
            }
            for (int i = 0;i< bb.Length;i++)
            {
                if (bb[i] ==0)
                {
                    Ans++;
                }
            }
            Console.WriteLine(Ans);
        }
    }*/
    //119B
    /*class Data
    {
        public double Get { get; set; }
        public string Which { get; set; }
    }
    class Program
    {
        static void Main()
        {
            double Ans = 0;
            List<Data> table = new List<Data>();
            Data data;
            int N = int.Parse(Console.ReadLine());
            for (int i=0;i< N; i++)
            {
                data = new Data();
                var w = Console.ReadLine().Split();
                data.Get = double.Parse(w[0]);
                data.Which = w[1];
                table.Add(data);
            }
            foreach(Data nn in table)
            {
                if (nn.Which == "JPY")
                {
                    Ans += nn.Get;
                }
                else
                {
                    Ans += (nn.Get/1.0) * 380000.0;
                }
            }
            Console.WriteLine(Ans);
        }
    }*/
    //117B
    /*class Program
    {
        static void Main()
        {
            int ans = 0;
            int N = int.Parse(Console.ReadLine());
            int[] length = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i =0;i<length.Length;i++)
            {
                ans += length[i];
            }
            ans = ans - length.Max();
            if (length.Max() < ans)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }*/
    //116B
    /*class Progaram
    {
        static void Main()
        {
            int Ans = 0;
            int S = int.Parse(Console.ReadLine());
            List<int> Answer = new List<int>();
            int ans = S;
            Answer.Add(S);
            bool bunn = false;
            while (true)
            {
                if (ans %2 ==0)
                {
                    ans = ans / 2;
                    Answer.Add(ans);
                }
                else if (ans % 2 == 1)
                {
                    ans = 3 * ans + 1;
                    Answer.Add(ans);
                }
                for (int i=0;i<Answer.Count;i++)
                {
                    for (int j =i+1;j<Answer.Count;j++)
                    {
                        if (Answer[i] == Answer[j])
                        {
                            Ans = j;
                            bunn =true;
                        }
                    }
                }
                if (bunn)
                {
                    break;
                }
            }
            Console.WriteLine(Ans+1);
        }
    }*/
    //115B
    /*class Program
    {
        static void Main()
        {
            int Answer = 0;
            int N = int.Parse(Console.ReadLine());
            List<int> price = new List<int>();
            for (int i=0;i<N;i++)
            {
                var temp = int.Parse(Console.ReadLine());
                price.Add(temp);
            }
            price.Sort();
            price.Reverse();
            price[0] = price[0] / 2;
            foreach (int n in price)
            {
                Answer += n;
            }
            Console.WriteLine(Answer);
        }
    }*/
    //114B
    /*class Program
    {
        static void Main()
        {
            int an = 0;
            List<int> Answer = new List<int>();
            string S = Console.ReadLine();
            char[] temp = new char[S.Length];
            for (int i=0;i<S.Length;i++)
            {
                temp[i] = S[i];
            }
            for (int i=0;i<S.Length-2;i++)
            {
                var a = Convert.ToInt32(temp[i].ToString());
                var b = Convert.ToInt32(temp[i + 1].ToString());
                var c = Convert.ToInt32(temp[i + 2].ToString());
                an = a * 100 + b * 10 + c;
                var tempAns = Math.Abs(753 - an);
                Answer.Add(tempAns);
            }
            Console.WriteLine(Answer.Min());
        }
    }*/
    //112B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int T = input[1];
            List<int[]> table = new List<int[]>();
            List<int[]> table2 = new List<int[]>();
            for (int i=0;i<N;i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                table.Add(temp);
            }
            foreach (int[] time in table)
            {
                if (time[1] <= T)
                {
                    table2.Add(time);
                }
            }
            List<int> anss = new List<int>();
            foreach (int[] ans in table2)
            {
                anss.Add(ans[0]);
            }
            if (anss.Count == 0)
            {
                Console.WriteLine("TLE");

            }
            else
            {
                Console.WriteLine(anss.Min());
            }
        }
    }*/
    //111B
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            /*int hun = N / 100;
            int ten = N / 10;
            int one = N % 10;*/
            while (true)
            {
                int hun = N / 100;
                int ten = N % 100 /10;
                int one = N % 10;
                if (hun == ten && ten == one && one == hun)
                {
                    break;
                }
                N++;

            }
            Console.WriteLine(N);
        }
    }
}