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 (Python):

"""
B - AtCoder Beginner Contest 111
https://atcoder.jp/contests/abc111/tasks/abc111_b

"""
import sys


def solve(N):
    while True:
        if len(set(str(N))) == 1:
            break
        N += 1
    return N


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):




n = int(input())


ans = (int(n / 111) + 1) * 111
if n % 111 == 0:
    ans -= 111


print(ans)

Solution (Python):
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools


import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n = int(input())

if n%111==0:
    print(n)
else:
    print((int(n/111)+1)*111)

Solution (Python):
if __name__ == '__main__':
    N = int(input())

    answer = -1
    for i in range(N, 1000):
        i_str = str(i)
        if i_str[0] == i_str[1] and i_str[1] == i_str[2]:
            answer = i_str
            break
    print(i_str)

Solution (Python):
n = int(input())
print((n + 110) // 111 * 111)

Solution (Python):
a = int(input())

b = [111,222,333,444,555,666,777,888,999]

for i in b:
    if i < a:
        continue
    else:
        print(i)
        break

Solution (Python):
a = input()
if int(a[0]) > int(a[1]):
  print(a[0]+a[0]+a[0])
elif int(a[0]) == int(a[1]) and int(a[0]) >= int(a[2]):
  print(a[0]+a[0]+a[0])
else:
  b = str(int(a[0]) + 1)
  print(b+b+b)

Solution (Python):
N = int(input())
for i in range(1, 10):
  if N <= i * 111:
    print(i * 111)
    break

Solution (Python):
def main():
    n = int(input())

    a = 111

    while (a < n):
        a += 111

    print(a)

if __name__=='__main__':
    main()

Solution (Python):


n=int(input())
print(n+(111-(n%111))%111)

Solution (Python):
N=int(input())
print(N+111-(N%111) if N % 111 != 0 else N)

Solution (Python):
n = int(input())

for i in range(n, 1000):
    if all([ii == str(i)[0] for ii in str(i)]):
        print(i)
        break

Solution (Python):
n=input()
n_list=list(n)

zoro=n[0]+n[0]+n[0]

if int(n) <= int(zoro):
  print(zoro)
else:
  print(str(int(n[0])+1) + str(int(n[0])+1) + str(int(n[0])+1))

Solution (Python):
n=int(input())
for i in range(1,10):
    if 100*i+10*i+i>=n:
        print(100*i+10*i+i)
        exit()

Solution (Python):
N = input()
if N <= N[0]*len(N):
    print(N[0]*len(N))
else:
    print(str(int(N[0])+1)*len(N))

Solution (Python):
n = int(input())

string_n = str(n)

third_digit = string_n[0]

next_third_digit = int(third_digit) + 1

if int(third_digit * 3) - n >= 0:
    print(int(third_digit * 3))
else:
    print(int(str(next_third_digit) * 3))

Solution (Python):
def main():
    N = input()
    ans = int(N[0]+N[0]+N[0])
    if ans < int(N):
        ans += 111
    print(ans)
main()

Solution (Python):
N = int(input())
ans = -1
while True:
    now = str(N)
    if now[0] == now[1] and now[1] == now[2]:
        ans = N
        break
    else:
        N += 1
print(ans)

Solution (Python):
n=int(input())
for i in range(n,1000):
    if len(set([x for x in str(i)]))==1:
        print(i)
        break

Solution (Python):

n = int(input())
print(min([i*111 for i in range(1, 10) if n <= i * 111]))

Solution (Python):
n = input()
n_int = int(n)
top = n[0]
if int(top)*111 >= n_int:
    print(int(top)*111)
else:
    print((int(top)+1)*111)

Solution (Python):
N = int(input())

for i in range(N, 1000, 1) : 
    num = str(i)
    if num[0] == num[1] and num[1] == num[2] : 
        print(num)
        break

Solution (Python):
n=int(input())
for i in range(111,1000,111):
        if n<=i:
                print(i)
                break

Solution (Python):
n = int(input())
ret = (n-1) // 111 + 1
print(ret * 111)

Solution (Python):
a=list(str(input()))
e=int(''.join(a))


b=int(a[1])-int(a[1]*111)
c=a[0]
c=int(c)
b = e-c*111
if b <=0:
  print(c*111)
else:
  c+=1
  print(c*111)

Solution (Python):
n = int(input())
for i in range(1, 10):
    m = 111 * i
    if n <= m:
        print(m)
        break

Solution (Python):
print((((int(input())-1)//111)+1)*111)

Solution (Python):

"""
Created on Thu May  9 23:00:25 2019

@author: Yamazaki Kenichi
"""
import sys

N = int(input())

for i in range(111):
    if N % 111 == 0:
        print(N)
        sys.exit()
    else:
        N += 1

Solution (Python):
N = input()

def check(n):
    for s in n:
        if s is not n[0]:
            return False
    return True

for i in range(int(N),1000):
    if check(str(i)):
        print(i)
        exit()

Solution (Python):
N = int(input())

if N%111 == 0:
  print(N)
else:
  head = N//111
  print((head+1) * 111)

Solution (Python):
N = int(input())
print(((N // 111) + 1) * 111 if N % 111 != 0 else (N // 111) * 111)

Solution (Python):
N=int(input())
for i in range(1,10):
    if 111*(i-1)<N<=111*i:
        print(111*i)

Solution (Python):
N = int(input())

candidate = [000, 111, 222, 333, 444, 555, 666, 777, 888, 999]

for i in range(len(candidate)-1):
    if candidate[i] < N <= candidate[i+1]:
        print(candidate[i+1])
        break

Solution (Python):
N = int(input())
print(min([111*i-N for i in range(1,10) if 111*i>=N])+N)

Solution (Python):
print(((int(input())-1)//111+1)*111)

Solution (Python):
print(((int(input())-1)//111+1)*111)

Solution (Python):
N = int(input())

print(N if N % 111 == 0 else (N // 111 + 1) * 111)

Solution (Python):
n = input()
a = int(n[0])
if n[0] > n[1]:
  print(a*111)
elif n[0] < n[1]:
  print((a+1)*111)
elif n[1] >= n[2]:
  print(a*111)
else:
  print((a+1)*111)

Solution (Python):
n = int(input())
if n < 100:
    while int(n/10) != n % 10:
        n = n + 1
    print(n)
else:
    while not (int(n/100)==int((n%100)/10) and int(n/100) == n%10):
        n = n + 1
    print(n)

Solution (Python):
n = list(input())
for i in range(len(n)):
        n[i] = int(n[i])
ans = n[0]
if n[0] < n[1] or (n[0] == n[1] and n[1]<n[2]):
        ans += 1
for i in range(3):
        print(ans,end="")

Solution (Python):
N = int(input())

for n in range(N, 1000):
    if n % 111 == 0:
        print(n)
        break

Solution (Python):
n = int(input())
print(((n-1) // 111 + 1) * 111)

Solution (Python):
a=int(input())
ans=111
while a>ans:
  ans+=111
print(ans)

Solution (Python):
N = int(input())
a = int(str(N)[0])
b = int(str(N)[1])
c = int(str(N)[2])
A = (a + 1) * 100 + (a + 1) * 10 + (a + 1)
B = a * 100 + a * 10 + a
if a < b:
    ans = A
elif a > b:
    ans = B
else:
    if b >= c:
        ans = B
    else:
        ans = A

print(ans)

Solution (Python):
N = input()
num = len(N)

a = list(map(int, N))

if max(a) == a[0]:
	print(N[0]*num)
else:
    print(str(a[0]+1)*num)

Solution (Python):
N = int(input())

a = (N-1)//111 + 1

print (111 * a)

Solution (Python):
n = int(input())
print(111*(1 + (n-1)//111))

Solution (Python):
N = input()
while any([c!=N[0] for c in N]):
    N=str(int(N)+1)
print(N)

Solution (Python):
n = int(input())
while n%111 != 0:
    n += 1
print(n)

Solution (Python):
n = int(input()); a = n // 100 * 111; print(a if n <= a else a + 111)

Solution (Python):


from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def main():
    n = intin()

    for i in range(n, 1000):
        i2 = i // 100
        i1 = (i // 10) % 10
        i0 = i % 10

        if i0 == i1 and i1 == i2:
            print(i)
            return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

for i in range(1,10):
    if n <= 111*i:
        break
print(111*i)

Solution (Python):
n = int(input())
print(min([i for i in range(100,1000) if i >= n and i//100 == (i//10)%10 and i//100 == i%10]))

Solution (Python):
n=int(input())
for i in range(999):
      if n%111==0:
            print(n)
            break
      else:
            n+=1

Solution (Python):
N = input()
tmp = N[0] * 3
if N > tmp:
    tmp = str(int(N[0])+1) * 3
print(tmp)

Solution (Python):
n = input()
N = []
N.append(int(n[0]))
N.append(int(n[1]))
N.append(int(n[2]))

if N[0] * 100 + N[0] * 10 + N[0] >= N[0] * 100 + N[1] * 10 + N[2]:
    print(N[0] * 100 + N[0] * 10 + N[0])
else:
    print((N[0] + 1) * 100 + (N[0] + 1) * 10 + (N[0] + 1))

Solution (Python):
n = int(input())
for i in range(1, 10):
    num = i * 111
    if n <= num:
        print(num)
        break

Solution (Python):
N = int(input())

for i in range(N, 1000):
    s = str(i)
    if s[0] == s[1] == s[2]:
        print(s)
        break

Solution (Python):
n=int(input())
for m in range(0,11):
 if 1+111*m<=n<=111+111*m:
  print(111*m+111)

Solution (Python):
N = int(input())
i = int(N/ 111)
if N% 111 != 0:
    i += 1
print(i * 111)

Solution (Python):
def solve():
    N = int(raw_input())
    ret = ((N - 1) // 111 + 1) * 111
    print str(ret)

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
s = int(input())
for i in range(10):
    if i*100+i*10+i< s <= (i+1)*100+(i+1)*10+(i+1):
        print((i+1)*100+(i+1)*10+(i+1))
        sys.exit()

Solution (Python):


from sys import stdin

N = stdin.readline().rstrip()

def main():
    if int(N) <= int(N[0]*len(N)):
        print(N[0]*len(N))
    else:
        print((str(int(N[0])+1))*len(N))

if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
for i in range(N,N+112):
    if N%111!=0:
        N+=1
    else:
        break
print(N)

Solution (Python):
print(((int(input()) + 110)//111) * 111)

Solution (Python):
abc = int(input())
for x in range(111, 1110, 111):
    if x >= abc:
        print(x)
        break

Solution (Python):
N = input()

for i in range(int(N), 10**9):
    if len(set(str(i))) == 1:
        ret = i
        break
print(i)

Solution (Python):
import math
print(math.ceil(int(input())/111)*111)

Solution (Python):
n=int(input())
a=[int(str(i)*3)-n for i in range(1,10)]
ans=[j for j in a if j>=0]
print(n+min(ans))

Solution (Python):
import sys
input = sys.stdin.readline

n = int(input())
for i in range(n, n + 111):
    temp = list(str(i))
    if temp[0]==temp[1]==temp[2]:
        print(i)
        exit()

Solution (Python):
N=input()
N=list(N)
Key=False
while Key==False:
    if N[0]==N[1] and N[1]==N[2]:
        break
    else:
        N=''.join(N)
        N=int(N)
        N+=1
        N=str(N)
        N=list(N)

N=''.join(N)
print(N)

Solution (Python):
N = list(map(int, input()))

if ((N[0]*100+N[1]*10+N[2]) < (N[0]*100+N[0]*10+N[0])):
    print(N[0]*100+N[0]*10+N[0])
elif ((N[0]*100+N[1]*10+N[2]) > (N[0]*100+N[0]*10+N[0])):
    print((N[0]+1)*100+(N[0]+1)*10+(N[0]+1))
else:
    print(N[0]*100+N[1]*10+N[2])

Solution (Python):
n=int(input())
while True:
    if n==111 or n==222 or n==333 or n==444 or n==555 or n==666 or n==777 or n==888 or n==999:
        print(n)
        break
    else:
        n+=1

Solution (Python):
print(-(-int(input()) // 111) * 111)

Solution (Python):
N = int(input())
print((N // 100 + 1 if N // 100 * 111 < N else N // 100) * 111)

Solution (Python):
n=int(input())
a,b=divmod(n,111)
if b==0:
  print(a*111)
else:
  print((a+1)*111)

Solution (Python):
n = int(input())

x = [111,222,333,444,555,666,777,888,999]
for i in x:
    if n <= i:
        break
print(i)

Solution (Python):
N = int(input().strip())
for i in range(10):
  if N <= 111*i:
    print(111*i)
    break

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    for i in range(N, 1000):
        if len(set(str(i))) == 1:
            return i


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
zoro=[111,222,333,444,555,666,777,888,999]
for i in range(len(zoro)):
  if N<=zoro[i]:
    print(zoro[i])
    break

Solution (Python):
N = int(input())
print(((N-1)//111+1)*111)

Solution (Python):
print(((int(input())-1)//111+1)*111)

Solution (Python):
n = input()
if (n[0] >= n[1] and n[0] >= n[2]): print(n[0]*3)
else: print(int(n[0]*3)+111)

Solution (Python):
n=input()
ans=int(n[0]*3)
if int(n)<=ans:
    print(ans)
else:
    print(ans+111)

Solution (Python):
N = int(input())
if N <= 111:
    print(111)
elif N <= 222:
    print(222)
elif N <= 333:
    print(333)
elif N <= 444:
    print(444)
elif N <= 555:
    print(555)
elif N <= 666:
    print(666)
elif N <= 777:
    print(777)
elif N <= 888:
    print(888)
else:
    print(999)

Solution (Python):
N = int(input())
A = N//100

print((A*111) if N <= A*111 else (A+1)*111)

Solution (Python):
N = int(input())
i = 1
while i*111<N:
    i += 1
print(i*111)

Solution (Python):
n=int(input())
if 100<=n<112:
	print("111")
elif 112<=n<223:
	print("222")
elif 223<=n<334:
	print("333")
elif 334<=n<445:
	print("444")
elif 445<=n<556:
	print("555")
elif 556<=n<667:
	print("666")
elif 667<=n<778:
	print("777")
elif 778<=n<889:
	print("888")
elif 889<=n<=999:
	print("999")

Solution (Python):
n = int(input())
for i in range(9):
    if n - 111 * (i) <= 111:
        print(111 * (i+1))
        break

Solution (Python):
N = (int(input()) - 1)
x = (N // 111) + 1
print(x*100 + x*10 + x)

Solution (Python):
n = int(input())
print(n if n%111 == 0 else 111 - n%111 + n)

Solution (Python):

N = input()
a = int(N[0])
X = a*100+a*10+a
if int(N) <= X:
    print(X)
else:
    print(X+111)

Solution (Python):
N = int(input())
print((N+111-1)//111*111)

Solution (Python):
n=int(input())
print((n+110)//111*111)

Solution (Python):
import sys

n = int(input())

for x in range(n, 1000):
  s = str(x)
  
  if s[0] == s[1] and s[1] == s[2]:
    print(s)
    sys.exit()

Solution (Python):
n = int(input())
print(n//111*111 if n%111 == 0 else (n//111 + 1)*111)

Solution (Python):
n=int(input())
print(n//111*111+111*(n%111!=0))

Solution (Python):
N=input()
N_list=list(N)
triple=[N[0],N[0],N[0]]
triple_one=[str(int(N[0])+1),str(int(N[0])+1),str(int(N[0])+1)]
num=int("".join(triple))
num_one=int("".join(triple_one))
N_int=int(N)
if N_int > num and N_int < num_one:
    ans = num_one
elif N_int <= num:
    ans= num

print(ans)

Solution (Python):
n = int(input())
i = n // 111
if n % 111:
    i += 1
print(i*111)

Solution (Python):
N = list(map(int,input()))
if N[0] > N[1] or (N[0] == N[1] and N[1] >= N[2]):
    print(N[0]*100+N[0]*10+N[0])
else:
    print((N[0]+1)*100+(N[0]+1)*10+(N[0]+1))

Solution (Python):
N = int(input())
ceil = 1000

for num in range(N, ceil):
    num = str(num)
    if num[0] == num[1] and num[0] == num[2]:
        print(int(num))
        break
    else:
        pass

Solution (Python):
n = int(input())
ans = 0
for i in range(9):
  j = i+1
  a = 100*j + 10*j + j
  if n <= a:
    ans = a
    break
  if n > a:
    k = j+1
    b = 100*k + 10*k + k
    if n < b:
      ans = b
      break
print(ans)

Solution (Python):
N = input()

p = ''
Flag = False
for s in N:
    if p == '':
        p = s
        continue
    else:
        if p == s:
            continue
        else:
            if int(p) > int(s):
                print(p * len(N))
                Flag = True
                break
            else:
                pref = str(int(p) + 1)
                print(pref * len(N))
                Flag = True
                break
if not Flag:            
    print(N)

Solution (Python):
def is_same(n):
    s = str(n)

    num = s[0]
    for x in s:
        if num != x:
            return False
    return True

N = int(input())

while True:
    if is_same(N):
        break
    N = N + 1

print(N)

Solution (Python):
a = int(input())

for i in range(10):
	if a<=i*111:
		print(i*111)
		break

Solution (Python):
N = int(input())
ABC = [111, 222, 333, 444, 555, 666, 777, 888, 999]
minimum = 10**9
answer = N
for i in ABC:
  sub = i-N
  if sub >= 0 and minimum > sub:
    minimum = sub
    answer = i
print(answer)

Solution (Python):
N = input()

for s in "123456789":
	if int(N) <= int(s * 3):
		print(s * 3)
		break

Solution (Python):
N = input()
if int(N[1] + N[2]) <= int(N[0] + N[0]):
	print(int(N[0] + N[0] + N[0]))
else:
	print((int(N[0]) + 1) * 100 + (int(N[0]) + 1) * 10 + (int(N[0]) + 1))

Solution (Python):
n=int(input())

a=n//100
b=(n-a*100)//10
c=n-a*100-b*10

if a==b:
    if a<c:
        print((a+1)*100+(a+1)*10+a+1)
    elif c<a:
        print(a*100+a*10+a)
    elif a==c:
        print(n)
elif a<b:
    print((a+1)*100+(a+1)*10+a+1)
elif a>b:
    print(a*100+a*10+a)

Solution (Python):
n = int(input())
if n < 112:
  print(111)
elif n < 223:
  print(222)
elif n < 334:
  print(333)
elif n < 445:
  print(444)
elif n < 556:
  print(555)
elif n < 667:
  print(666)
elif n < 778:
  print(777)
elif n < 889:
  print(888)
else:
  print(999)

Solution (Python):


def main():
    a = int(input())
    for i in range(a, 1000):
        a1, a2, a3 = list(str(i))
        if a1 == a2 == a3:
            print(i)
            break

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
while True:
  if len(set(str(N))) == 1:
    print(N)
    break
  N += 1

Solution (Python):
from math import ceil
print(ceil(int(input()) / 111) * 111)

Solution (Python):

from math import ceil
n = int(input())

print(ceil(n / 111) * 111)

Solution (Python):
N = input()
n = int(N[0])*100 + int(N[0])*10+int(N[0])*1
if int(N) - n <= 0:
    print(n)
else:
    print(n + 111)

Solution (Python):
N = input()
n = int(N[0])*100 + int(N[0])*10+int(N[0])*1
if int(N) - n <= 0:
    print(n)
else:
    print(n + 111)

Solution (Python):
import sys
N = int(input())

for n in range (N,1000):
    str_n = str(n)
    if str_n[0] == str_n[1] == str_n[2]:
        print(n)
        sys.exit()

Solution (Python):
N=int(input())
for i in range(900):
  if (N+i)%111==0:
    print(N+i)
    exit()

Solution (Python):

from math import ceil

num = int(input())
print(ceil(num / 111) * 111)

Solution (Python):

from math import ceil

print(ceil(int(input()) / 111) * 111)

Solution (Python):

from math import ceil

num = int(input())
i = ceil(num / 111)
print(i * 111)

Solution (Python):
s=input()
print(str(int(s[0])+1)*3 if s[0]*3<s else s[0]*3)

Solution (Python):
N = int(input())

for i in range(N, 1000):
    stri = str(i)
    if stri[0] == stri[1] == stri[2]:
        print(i)
        break

Solution (Python):
N = str(input())
if N[0] == N[1] == N[2]:
    print(N)
    exit()
else:
    for i in range(int(N), 1000):
        tmp = str(i)
        if tmp[0] == tmp[1] == tmp[2]:
            print(tmp)
            exit()

Solution (Python):

import sys


def solve(N: int):
    ret = ''
    for i in range(N, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            ret = s
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int):
    for i in range(1, 10):
        n = int(str(i)*3)
        if N <= n:
            break
    else:
        print("1111")
        return
    print(n)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):
N, = (int(x) for x in input().split())

for i in range(1,10):
    iii = i*111
    if N <= iii:
        break

print(iii)

Solution (Python):


n = int(input())

a, b = divmod(n, 111)

if b == 0:
    print(111*a)
else:
    print(111*(a+1))

Solution (Python):
n = int(input())

for i in range(111,889,111):
  if n <= i:
    print(i)
    break
else: print(999)

Solution (Python):

N =int(input())

for i in range(N,99999):
    if len(set(list(str(i))))==1:
           print(i)
           exit()

Solution (Python):
N = int(input())
for i in range(1, 10):
    if 111 * i >= N:
        print(111 * i)
        break

Solution (Python):
n=input();s=n[0]*3;print([n,[s,str(int(n[0])+1)*3][int(s)<int(n)]][int(n)%111>0])

Solution (Python):


n = int(input())

a, b = divmod(n, 111)

if b == 0:
    print(111*a)
else:
    print(111*(a+1))

Solution (Python):
n=int(input())
print((((n-1)//111)+1)*111)

Solution (Python):
N = int(input())
print(111*(N//111+1) if N%111!=0 else 111*(N//111))

Solution (Python):
n=int(input())
if n%111==0:
  print(n)
else:
  import math
  print(111*math.ceil(n/111))

Solution (Python):
from math import ceil
print(111*ceil(int(input())/111))

Solution (Python):
import math

n=int(input())
q=math.ceil(n/111)
print(111*q)

Solution (Python):

N = int(input())

list = [111,222,333,444,555,666,777,888,999, 1000000]
ans = 0
for l in list:
  if N > l:
    continue
  else:
    ans =l
    break

print(ans)

Solution (Python):
n = int(input())
num = 111

while num <= 999:
    if n <= num:
        print(num)
        break
    else:
        num += 111

Solution (Python):
n = int(input())
x = n
while True:
    flag = False
    first_s = str(x)[0]
    if all(s == first_s for s in str(x)):
        print(x)
        exit()
    x += 1

Solution (Python):
N=int(input())
print(((N-1)//111+1)*111)

Solution (Python):

import sys
import copy
from bisect import bisect_left

def main():
	N = int(input())
	
	for i in range(N, 1000):
		tmp = i % 10
		ans = ""
		tugi = 0
		isOK = True
		for j in range(len(str(i))):
			if j == 0:
				tugi = i
			tmp2 = tugi % 10
			tugi = tugi // 10
			ans += str(tmp)
			if tmp != tmp2:
				isOK = False
				break
		if isOK == True:
			print(ans)
			sys.exit()
		
	
if __name__ == "__main__":
	main()

Solution (Python):
x=int(input())
for y in range(1, 10):
	if x <= y*111:
		print(y*111)
		break

Solution (Python):
N = input()
digit_3 = int(N[2])
N = int(N)
nums = [111,222,333,444,555,666,777,888,999]
for num in nums[::-1]:
    temp = num - N
    if temp < 111:
        print(num)
        break

Solution (Python):
n = int(input())
num = [111, 222, 333, 444, 555, 666, 777, 888, 999]
min_ = 111
ans = 0
for i in num:
  if i-n<0:
    None
  else:
    if min_ > i-n:
      ans = i
print(ans)

Solution (Python):
n = int(input())
if n <= 111:
    print(111)
elif n <= 222:
    print(222)
elif n <= 333:
    print(333)
elif n <= 444:
    print(444)
elif n <= 555:
    print(555)
elif n <= 666:
    print(666)
elif n <= 777:
    print(777)
elif n <= 888:
    print(888)
else:
    print(999)

Solution (Python):
N = int(raw_input())
ans = (N / 111 + 1) * 111
if N % 111 == 0: ans -= 111
print ans

Solution (Python):
N = int(input())

rev1 = (N//100) * 100 + (N//100) * 10 + (N//100)
rev2 = (N//100 +1) * 100 + (N//100+1) * 10 + (N//100+1)

if N <= rev1 <= rev2:
  print(rev1)
else:
  print(rev2)

Solution (Python):
print(((int(input())-1)//111+1)*111)

Solution (Python):
N = int(input())

candidate = [111,222,333,444,555,666,777,888,999]

for c in candidate:
    if N <= c:
        print(c)
        break

Solution (Python):
N = input()
n = [int(i) for i in N]
N = int(N)
a = n[0]
b = len(n)
c = 0

for i in range(b):
    c += a*10**i

if N <= c:
    print(c)
else:
    c = [str(int(i)+1) for i in str(c)]
    print(''.join(c))

Solution (Python):
n=input()
m=n[0]
for i in range(len(n)-1):
  m+=n[0]
if int(n)>int(m):
  if n[0]!=str(9):
    a=str(int(n[0])+1)
    for j in range(len(n)-1):
      a+=str(int(n[0])+1)
    print(a)
  else:
    b=str(1)
    for k in range(len(n)):
      b+=str(1)
    print(b)
else:
  print(m)

Solution (Python):
N = int(input())
for i in range(N, 1000):
  if i % 111 == 0:
    print(i)
    exit()

Solution (Python):
N = int(input())
x = [i*100 +i* 10+i for i in range(1, 10)]
for i in x:
  if i >= N:
    print(i)
    break

Solution (Python):
N = int(input())
list = [111 * i for i in range(1,10)]
num = 0

for i in list:
    if N <= i:
        num = i
        break

print(num)

Solution (Python):
N = int(input())
print(111 * (((N - 1) // 111) + 1))

Solution (Python):
n = int(input())
import bisect
a = [111,222,333,444,555,666,777,888,999]
x = bisect.bisect_left(a,n)
print(a[x])

Solution (Python):
n = int(input())

k = n//111
if n%111 == 0:
    print(k*111)
else:
    print((k+1)*111)

Solution (Python):
n = int(input())

x = n // 100

if n <= x * 111:
  print(x * 111)
else:
  print((x + 1) * 111)

Solution (Python):
N = input()
thr = int(N[0]*3)
print(thr if int(N)<=thr else thr+111)

Solution (Python):
n=int(input())
while True:
  if n%111==0:
    break
  n+=1
print(n)

Solution (Python):
n = int(input())
for i in range(0, 9):
    if i * 111 < n <= (i + 1) * 111:
        print((i + 1) * 111)
        break

Solution (Python):
n = int(input())
if n <= 111:
	print(111)
elif n <= 222:
	print(222)
elif n <= 333:
	print(333)
elif n <= 444:
	print(444)
elif n <= 555:
	print(555)
elif n <= 666:
	print(666)
elif n <= 777:
	print(777)
elif n <= 888:
	print(888)
else:
	print(999)

Solution (Python):
X = int(input())

if 100 <= X <= 111:
  n = 111
elif X <= 222:
  n = 222
elif X <= 333:
  n = 333
elif X <= 444:
  n = 444
elif X <= 555:
  n = 555
elif X <= 666:
  n = 666
elif X <= 777:
  n = 777
elif X <= 888:
  n = 888
elif X <= 999:
  n = 999
else:
  print("error")

print(n)

Solution (Python):
n = int(input())
for i in range(10):
    if i*111 < n <= (i+1)*111:
        print((i+1)*111)
        break

Solution (Python):
n = int(raw_input())
if n % 111 == 0:
	print n
else:
	print 111 * int(n / 111 + 1)

Solution (Python):
N = int(input())

if N <= 111:
  print('111')
elif N <= 222:
  print('222')
elif N <= 333:
  print('333')
elif N <= 444:
  print('444')
elif N <= 555:
  print('555')
elif N <= 666:
  print('666')
elif N <= 777:
  print('777')
elif N <= 888:
  print('888')
elif N <= 999:
  print('999')

Solution (Python):
N = int(input())
l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(len(l)):
  if N <= l[i]:
    print(l[i])
    break

Solution (Python):
n = int(input())

if n % 111 == 0:
    print(n)
else:    
    print(n + 111 - n % 111)

Solution (Python):
n = int(input())
for i in range(n,1000):
    if len(set(list(str(i))))==1:
        print(i)
        break

Solution (Python):
n = int(input())
abc = [999,888,777,666,555,444,333,222,111]

for i in abc:
    if n <= i:
        ans = i

print(ans)

Solution (Python):
N = int(input())

if N%111 == 0:
    print(N)
    exit()

for n in range(N,1000):
    if n%111 == 0:
        print(n)
        exit()

Solution (Python):
N = input()
x = N[0]
if int(N) > int(x * 3):
  x = str(int(x) + 1)
print(x * 3)

Solution (Python):
N = int(input())
i = 1
while True:
    if 111 * i >= N:
        print(111 * i)
        break
    else:
        i += 1

Solution (Python):
N = int(input())
if N <= 111:
    print(111)
elif N <= 222:
    print(222)
elif N <= 333:
    print(333)
elif N <= 444:
    print(444)
elif N <= 555:
    print(555)
elif N <= 666:
    print(666)
elif N <= 777:
    print(777)
elif N <= 888:
    print(888)
elif N <= 999:
    print(999)

Solution (Python):
N = input()
 
if int(N) <= int(N[0] * 3):
    print(int(N[0] * 3))
else:
    print(int(str((int(N[0]) + 1)) * 3))

Solution (Python):
q,m=divmod(int(input()),111);print((q+1*(m>0))*111)

Solution (Python):
N = int(input())
print(111*((N+110)//111))

Solution (Python):
N = int(input())

for num in range(N, 1000):
    if len(set(str(num))) == 1:
        print(num)
        exit()

Solution (Python):
n = int(input())
if n % 111 == 0:
  print(n)
else:
  print(111 * ((n // 111) + 1))

Solution (Python):
N = int(input())

def main():
    base = 111
    ans = base
    while ans < N:
        ans = ans + base
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
x=[111*i for i in range(1,10)]
for i in x:
  if i>=n:
    print(i)
    break

Solution (Python):
def main():
    N = int(input())
    flag = True
    i = N
    while flag:
        if str(i)[0] == str(i)[1] and str(i)[1] == str(i)[2]:
            print(i)
            flag = False
        i += 1


main()

Solution (Python):
N = int(input())

ans = (N+111-1)/111
ans = int(ans)
ans *= 111

print(ans)

Solution (Python):
N = int(input())
s = ''
def ans(N):
    for ctr in range(N,1000):
        s = str(ctr)
        if s[0]==s[1] and s[1]==s[2]:
            return(ctr)
print(ans(N))

Solution (Python):
N=input()
if int(N[0]*3)>=int(N):
  print(int(N[0]*3))
else:
  print(int(str(int(N[0])+1)*3))