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-----
111

-----Sample Output-----
111

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

Difficulty: introductory

Starter code:

Solutions:
N = int(input())
list_ = [111,222,333,444,555,666,777,888,999]
for i in list_:
    if i >= N:
        print(i)
        return

n = int(input())

while True:
  n = str(n)
  if n[0] == n[1] == n[2]:
    break
  n = int(n) + 1
print(n)

N=int(input())

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

print((((int(input())-1)//111+1)*111))


import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

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

    return


def __starting_point():
    main()

__starting_point()

n = int(input())

h = n // 100
x = h * 100 + h * 10 + h
print(x) if n <= x else print(x + 111) 


#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())

q, mod = divmod(n,111)

if mod == 0:
    print((q*111))
else:
    print(((q+1)*111))



N = int(input())

ans = ''
for i in range(1, 10):
    ans = str(i) * 3
    if int(ans) >= N:
        print(int(ans))
        return

n = input()
for i in range(int(n), 1000):
  if str(i).count(str(i)[0]) == 3:
    print(i)
    return

import sys
input = sys.stdin.readline


def main():
    N = int(input())

    for i in range(N, 1111111):
        x = set(list(str(i)))
        if len(x) == 1:
            print(i)
            return


def __starting_point():
    main()


__starting_point()

n = int(input())

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

a = int(input())
for i in range(10):
  if i * 111 >= a:
    print((i * 111))
    break
  else:
    continue
    




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

n = int(input())

print(111 * ((n-1) // 111 + 1))

n,i=int(input()),1
while n>111*i:
    i+=1
print(111*i)

n = input()
a = n[0] * 3
b = str(int(n[0])+1) * 3
print((a if a >= n else b))


n = input()
if int(n[0]*len(n)) >= int(n):
    print(n[0]*len(n))
else:
    print(str(int(n[0])+1)*len(n))

n = int(input())
a = 111
for _ in range(9):
    if n <= a:
        print(a)
        return
    a += 111

n = int(input())
ans = 111

for i in range(9):
    if n <= ans:
        print(ans)
        return
    else:
        ans += 111

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

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

n = int(input())
li = [int(str(i)*3) for i in range(10)]
import bisect
x = bisect.bisect_left(li,n)
print(li[x])

N = int(input())
lst = [i + i * 10 + i * 100 for i in range(1, 10)]

for l in lst:
    if N <= l:
        print(l)
        break

print((((int(input())-1)//111)+1)*111)

n = list(input())
x = int(n[0]*3)
y = int(n[0]+n[1]+n[2])
if x >= y:
  print(x)
else:
  print(x+111)

n = int(input())
a = (n-1)//111+1
print(a*100+a*10+a)

N = int(input())

if N % 111:
    print((111*(N//111 + 1)))

else:
    print((111*int((N/111))))


n = int(input())
while True:
    s = str(n)
    if s[0] == s[1] and s[0] == s[2]:
        print(n)
        break
    n += 1

A=input()
for i in range(int(A),1000):
   if len(set(str(i)))==1:
      print(i)
      return

N = int(input())

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

for i  in ans_list:
  if i >= N:
    print(i)
    break
    


import sys
n = int(input())

for i in range(n,1000):
    a = i//100
    b = (i - a*100)//10
    c = i - a*100-b*10
    if a == b == c:
        print(i)
        return

N = input()

if N[0] == N[1] == N[2]:
    print(int(N))

else:
    if int(N[0]) < int(N[1]):
        x = (int(N[0])+1) * 100 + (int(N[0])+1) * 10 + int(N[0])+1
        print(x)

    elif N[0] == N[1] and int(N[1]) > int(N[2]):
        x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
        print(x)

    elif N[0] == N[1] and int(N[1]) < int(N[2]):
        x = (int(N[0])+1) * 100 + (int(N[0])+1) * 10 + int(N[0])+1
        print(x)

    elif int(N[0]) > int(N[1]):
        x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
        print(x)

n = int(input())

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

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



url = "https://atcoder.jp//contests/abc111/tasks/abc111_b"

def main():
    s = input()
    for n in range(int(s), 1000):
        str_n = str(n)
        if len(str_n) == str_n.count(str_n[0]):
            print(n)
            return



def __starting_point():
    main()

__starting_point()

import sys

N = int(input())

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

N = input()
max_digit = N[0]

min_tmp = ''
max_tmp = ''
for i in range(len(N)):
    min_tmp += max_digit
    max_tmp += str(int(max_digit) + 1)
    
if  int(min_tmp) >= int(N):
    print(min_tmp)
else:
    print(max_tmp)

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

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

for i in range(int(input()),1000):
  if i%111==0:
    print(i)
    break

# B AtCoder Beginner Contest 111
N = list(input())
n = int("".join(N))
ck = int(N[0] * 3)
if n - ck <= 0:
    print((int(N[0] * 3)))
else:
    print((int(str(int(N[0])+1)*3)))
pass


n = input()
a = int(n[0]*3)
if int(n) <= a:
    print(a)
else:
    print(str(int(n[0])+1)*3)

n = int(input())

for i in range(n, 1000):
    a = i // 100
    b = (i - a * 100) // 10
    c = i - a * 100 - b * 10
    if a == b == c:
        print(i)
        return


n = int(input())
for i in range(n,n + 111):
    s = str(i)
    if s[0]== s[1] and s[1] == s[2]:
        print(i)
        break

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


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

n_list=list(input())

n=[int(i) for i in n_list]

ans=str(n[0]+1)*3

if n[0]>n[1]:
    ans=str(n[0])*3

elif n[0]==n[1]:
    if n[1]>=n[2]:
        ans=str(n[0])*3
        
print(ans)


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

N = int(input())

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

N=int(input())

def ans111(N:int):
    while N<=999:
        if str(N)[0]==str(N)[1]==str(N)[2]:
            break
        else:
            N+=1
    return N

print(ans111(N))

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

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

N = int(input())
count=0
for i in range(1,10):
    if (N-1)//int(str(i)*3)>=1:
        count=i
print((str(count+1)*3))


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


import sys
n=input()
n=list(n)

if n[0]>n[1]:
  print((n[0]*3))
  return

if n[0]<n[1]:
  print((str((int(n[0])+1))*3))
  return
  
if n[0]==n[1]>=n[2]:
  print((n[0]*3))
  return

if n[0]==n[1]<n[2]:
  print((str((int(n[0])+1))*3))
  return


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

N = int(input())
ans_N = 111
while True:
  if ans_N >= N: break
  ans_N += 111
print(ans_N)

n = int(input())

if n % 111 ==0:
    print(n)
    return

while n % 111 != 0:
    n += 1
    if n % 111 == 0:
        print(n)
        return

def answer(n: int) -> int:
    q = n // 111
    if n % 111 != 0:
        q += 1

    return 111 * q


def main():
    n = int(input())
    print((answer(n)))


def __starting_point():
    main()

__starting_point()

n = int(input())
div_n = -(-n // 111)
print(111 * div_n)

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
for i in range(n,1000):
    s = str(i)
    if s[0] == s[1] == s[2]:
        print(i)
        return


n = int(input())
for i in range(1, 10):
    l = [i, i, i]
    num = int(''.join(map(str, l)))
    if n <= num:
        print(num)
        break

a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print((c+1)*111)

n = int(input())

ans = 0
flag = 0
for i in range(n,1000): 
    s = str(i)
    n_list = list(s)
    if n_list[0] == n_list[1] and n_list[1] == n_list[2] and flag == 0:
        flag = 1
        ans = i
        
print(ans)

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

N=int(input())
print(111*(0--N//111))

n = int(input())
for i in range(n, 1000):
    if i%111 == 0:
        print(i)
        return

n = int(input())

for i in range(110):
    if n % 111 == 0:
        break
    else:
        n += 1
        
print(n)

import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
    n = int(input())
    for i in range(n, 1000):
        flag = True
        for j, c in enumerate(str(i)):
            if j == 0:
                continue
            else:
                if c != str(i)[0]:
                    flag = False
                    break
        if flag:
            return i

def __starting_point():
    print((main()))

__starting_point()

# ABC111

N = int(input())

zorome_contest = [111*i for i in range(1, 10)]
diff_min = 10**10
ans = 0

for contest in zorome_contest:
    if contest - N >= 0 and contest - N < diff_min:
        diff_min = contest - N
        ans = contest
print(ans)


N = int(input())
S = str(N)
x = int(S[0])
y = int(S[1])
z = int(S[2])
if x > y:
    ans = x*100+x*10+x
elif x < y:
    x += 1
    ans = x*100+x*10+x
else:
    if x > z:
        ans = x*100+x*10+x
    elif x < z:
        x += 1
        ans = x*100+x*10+x
    else:
        ans = N
print(ans)


x = input ()
if int(x[0])>int(x[1]):
  print (x[0]*3)
elif int(x[0])==int(x[1]):
  if int(x[0])>=int(x[2]):
    print (x[0]*3)
  else:
    print (str(int(x[0])+1)*3)
else:
  print (str(int(x[0])+1)*3)

s=input()
if int(s[0])<int(s[1]):
    print(111*(int(s[0])+1))
elif int(s[0])==int(s[1])<int(s[2]):
    print(111*(int(s[0])+1))
else:
    print(111*int(s[0]))

n = int(input())
str_n = str(n)
keta = len(str_n)
suji = [str(i) for i in range(10)]
#print(str_n,keta,suji)
ans = 0
for i in range(int(str_n[0]),10):
    tmp = ''
    for j in range(keta):
        tmp += suji[i]
    #print(tmp)
    if int(tmp)>=n:
        ans = int(tmp)
        break
print(ans)



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

n = input()
print(n[0]*3) if int(n) <= int(n[0]*3) else print(str(int(n[0])+1)*3)

n = int(input())
c = [111,222,333,444,555,666,777,888,999]
for i in range(9):
    if c[i] >= n:
        print(c[i])
        break

# import math
# import statistics
a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(i)
#e1,e2 = map(int,input().split())
#f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# zoro = int(a[0]*len(a))
zyun= len(a)*9+int(a[0])
zoro=0
z = zyun//9
af= zyun%9
if af==0:
    if int(a)<=int(str(9)*(z-1)):
        print((int(str(9)*(z-1))))
    else:
            print((str(1)*(z)))
else :
    if int(a)<=int(str(af)*(z)):
        print((int(str(af)*(z))))
    else:
        print((int(str(af+1)*(z))))




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

def isSame(n):
    if n[0] == n[1] and n[1] == n[2]:
        return True
    else:
        return False

n_s = input()
n_i = int(n_s)

while True:
    if isSame(n_s):
        print(n_s)
        break
    else:
        n_i += 1
        n_s = str(n_i)


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)

n=int(input())
from math import ceil
print((ceil(n/111)*111))


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

x = int(input())
for i in range(x, 1000):
  if i // 100 == i % 10 and i // 100 == (i // 10) % 10:
    break
print(i)

def main():
    n = int(input())
    for i in range(n, 1000):
        if len(set(list(str(i)))) == 1:
            print(i)
            return


main()


n = int(input())

while True:
  n = str(n)
  if n[0] == n[1] == n[2]:
    break
  n = int(n) + 1
print(n)

n=int(input())
hyaku=(n-n%100)/100
if n%100>hyaku*10+hyaku:
    hyaku+=1
    print(int(hyaku*100+hyaku*10+hyaku))
else:
    print(int(hyaku*100+hyaku*10+hyaku))

n = input()

if int(n[1]) < int(n[0]):
    ans = int(n[0] * 3)
elif int(n[0]) == int(n[1]) and int(n[2]) <= int(n[1]):
    ans = int(n[0] * 3)
else:
    ans = int(str(int(n[0]) + 1) * 3)

print(ans)

n = int(input())
a = -(-n//111)
if a == 10:
    print(1111)
else:
    print(a*111)

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


i = int(input())

for i in range(i, 1000):
    a = int((i/10)%10)
    b = int(i % 10)
    c = int(i /100)
    if a == b and b == c and c == a:
        print(i)
        return

N = int(input())

while N % 111 != 0:
    N += 1

print(N)


def main():
    n = input()
    if n[0] == '0':
        print('111')
    elif n[0] < n[1] or n[0] < n[2]:
        print(((int(n[0]) + 1) * 111))
    else:
        print((int(n[0]) * 111))


def __starting_point():
    main()

__starting_point()

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)

a = int(input())
for i in range(1, 9+1):
    if a <= (t := i*111):
        print(t)
        return


N = int(input())
for i in range(1,10):
    if 111*i >=N and N > 111*(i-1):
        print(111*i)
        return

n=input()
k = int(n) % 111
if k==0:
    print(n)
else:
    if n[0]>n[1] or (n[0]==n[1] and n[1]>n[2]):
        print(n[0]*3)
    else:
        print((str(int(n[0])+1))*3)

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

N = int(input())

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

else:
  for i in range(110):
    N += 1
    if N % 111 == 0:
      break
      
  print(N)
  


N = int(input())

f = N
while True:
  x = str(f)
  if all(x[i] == x[0] for i in range(len(x))):
    print(x)
    return
  else:
    f += 1