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.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        const bool IsTest = false;

        const string t1 = "111";
        const string t2 = "112";
        public static void Main(string[] args)
        {
            if (!IsTest) {
                new Program().Solve(new ConsoleInput(Console.In));
            } else {
                new Program().Solve(new ConsoleInput(new StringReader(t1)));
                new Program().Solve(new ConsoleInput(new StringReader(t2)));
            }
        }

        public void Solve(ConsoleInput cin)
        {
            cin.ReadLine();
            var N = cin.Read<int>();
            Console.WriteLine(((N + 110) / 111) * 111);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private readonly char _separator = ' ';
        private string _curLine;
        private string[] _curLineSplitted;
        private int _curItemIndex;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
        }
        public T Read<T>()
        {
            var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(T));
            if (converter == null) {
                throw new Exception(string.Format("TypeDescriptor.GetConverter {0}", typeof(T).Name));
            }
            return (T)converter.ConvertFromString(ReadString());
        }
        public T[] ReadArray<T>(long N)
        {
            var ret = new T[N];
            for (long i = 0; i < N; i++) {
                ret[i] = Read<T>();
            }
            return ret;
        }
        public Tuple<T> ReadLineAs<T>()
        {
            ReadLine();
            return new Tuple<T>(Read<T>());
        }
        public Tuple<T, S> ReadLineAs<T, S>()
        {
            ReadLine();
            return new Tuple<T, S>(Read<T>(), Read<S>());
        }
        public Tuple<T, S, U> ReadLineAs<T, S, U>()
        {
            ReadLine();
            return new Tuple<T, S, U>(Read<T>(), Read<S>(), Read<U>());
        }
        public Tuple<T, S, U, V> ReadLineAs<T, S, U, V>()
        {
            ReadLine();
            return new Tuple<T, S, U, V>(Read<T>(), Read<S>(), Read<U>(), Read<V>());
        }
        public Tuple<T, S, U, V, R> ReadLineAs<T, S, U, V, R>()
        {
            ReadLine();
            return new Tuple<T, S, U, V, R>(Read<T>(), Read<S>(), Read<U>(), Read<V>(), Read<R>());
        }

        public string ReadString()
        {
            return _curLineSplitted[_curItemIndex++];
        }
        public void ReadLine()
        {
            _curLine = _stream.ReadLine();
            if (_curLine == null) {
                throw new System.Exception("No more lines");
            }
            _curLineSplitted = _curLine.Split(_separator);
            _curItemIndex = 0;
        }
    }
}