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):
import itertools
import math
import fractions
import functools
n = int(input())

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

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

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

for i in range(1,10):
    if int(n)>int(str(i)*3):
        continue
    print(str(i)*3)
    break

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

Solution (Python):

n = int(input())

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

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

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

t = 0
    
while t*111 < n  and n > (t+1)*111:
    t += 1
    
print((t+1)*111)

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

if S[0] == S[1] == S[2]:
    print(N)
else:
    print(111 * (N // 111 + 1))

Solution (Python):
N = int(input())
x = 111
while x < N:
    x += 111
print(x)

Solution (Python):
n = int(input())
temp = (n // 100) * 111
print(temp if temp >= n else temp + 111)

Solution (Python):
n = int(input())
for x in range(111, 1000, 111):
    if x >= n:
        print(x)
        exit()

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

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

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

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

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

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

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

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

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

Solution (Python):
N=input()
if len(set(N))==1:
    print(int(N))
else:
    for i in range(111,1110,111):
        if i>=int(N):
            print(i)
            exit()

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

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

Solution (Python):
n = int(input())
v = [999,888,777,666,555,444,333,222,111]
ans = 0
for i in range(9):
    if v[i] >= n:
        ans = v[i]
print(ans)

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

Solution (Python):
n = int(input())
for i in [str(i)*3 for i in range(10)]:
    if int(i) >= n:
        print(int(i))
        break

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

Solution (Python):

import sys


def solve(N: int):
    print(-(-N // 111) * 111)


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(input())

for i in range(n,1000):
    j = set(list(str(i)))
    if(len(j) == 1):
        print(i)
        exit()

Solution (Python):

n = int(input())
l = []
for i in range(1, 10):
    x = int(str(i) + str(i) + str(i))
    if x >= n:
        print(x)
        exit()

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

cand=[111,222,333,444,555,666,777,888,999]
n=I()
for i in range(n,1000):
    if i in cand:
        print(i)
        sys.exit()

Solution (Python):
n=int(input())
t=111
c=1
while t<n:
  c+=1
  t=111*c
print(t)

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

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

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

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

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

ans = 999

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

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = ''
for x in range(N, 1000):
    temp = str(x)
    if len(set(temp)) == 1:
        answer = x
        break

print(answer)

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

for i in range(111):
    if (n+i)%111 == 0:
        print(n+i)
        exit(0)

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

while 1:
    if N % 111 == 0:
        print(N)
        break
    N += 1

Solution (Python):
n = int(input())
contest = [int(str(i)+str(i)+str(i)) for i in range(1, 10)]
for i in range(9):
    if n <= contest[i]:
        print(contest[i])
        break

Solution (Python):
n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n >= 0:
        apple.append(i)

print(min(apple))

Solution (Python):
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    while True:
        if len(set(str(n))) == 1:
            break
        n += 1
    print(n)
if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n=int(input())
i=0
while i<n:
  i+=111
print(i)

Solution (Python):
n = int(input())
x = int(str(n)[0])
y = x*100 + x*10 + x 

if n <= y :
  print(y)
else:
  print(y+111)

Solution (Python):
C=[]
for i in range(1,10):
    C.append(i*111)

N = int(input())

for k in range(9):
    if N <= C[k]:
        print(C[k])
        break

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
for i in range(1, 10):
	if 100*i + 10*i + i >= N:
		print(100*i + 10*i + i)
		exit()

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):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

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

while True:
  flag = False
  for i in range(len(str(n))-1):
    if str(n)[i] == str(n)[i+1]:
      flag = True
      
    elif str(n)[i] != str(n)[i+1]:
      flag = False
      break
  
 
  if flag:
    print(n)
    break
  n +=1

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

Solution (Python):
C=[]
for i in range(1,10):
    C.append(i*111)
n=int(input())
now=0
while C[now]<n:
    now+=1
print(C[now])

Solution (Python):
from bisect import bisect_left, bisect_right
N = int(input())

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

ans =bisect_left(L,N)
print(L[ans])

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

Solution (Python):

n = int(input())

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

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

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

print((0 - -n//111)*111)

Solution (Python):
n = input()
n0 = int(n[0])
n1 = int(n[1])
n2 = int(n[2])


if max(n0, n1, n2) == n0 or n2 >= n0 > n1:
    print(n[0]*3)
else:
    print(str(n0 + 1)*3)

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

Solution (Python):
n = int(input())
for i in range(n,1000):
  l = str(i)
  if l[0] == l[1] == l[2]:
    print(int(l))
    quit()

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

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

Solution (Python):



n = int(input())

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

print(111*i)

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

Solution (Python):
N = input()
x = N[:1]*3
if N > x:
    ans = str(int(N[:1])+1)*3
else:
    ans = x
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):
icase=0
if icase==0:
    n=int(input())
    for i in range(n,1000):
        istr=str(i)
        if istr[0]==istr[1] and istr[1]==istr[2]:
            print(i)
            break

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

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

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

Solution (Python):

n = input()

n = '10' if len(n) == 1 else n

while len(set(n)) != 1:
    n = str(int(n) + 1)

print(n)

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

Solution (Python):
def main():
    N = int(input())
    for i in range(N, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            print(i)
            break
main()

Solution (Python):


data=int(input())
nim=data//100
if data<=nim*111:
    print(nim*111)
else:
    print((nim+1)*111)

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

while str(n)[0] != str(n)[1] or str(n)[1] != str(n)[2]:
    n+=1

print(n)

Solution (Python):


def solve():

    N = int(input())
    for i in range(100, 1000):
        si = str(i)
        if N <= i:
            if si[0] == si[1] == si[2]:
                print(i)
                exit()


if __name__ == "__main__":
    solve()

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

while str(n)[0] != str(n)[1] or str(n)[1] != str(n)[2]:
    n+=1

print(n)

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

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

for i in range(1, 9):
  abc = 111 * i
  if n <= abc:
    print(abc)
    break
else:
  print(999)

Solution (Python):
n=int(input())
for i in range(n,1000):
  l=str(i)
  if l[0]==l[1] and l[1]==l[2]:
    print(i)
    break
  else:
    continue

Solution (Python):
N = input()

a = N[0]

def judge(N,a):
    pt = 0
    while pt < len(N):
        if int(N[pt]) < a:
            return False
        elif int(N[pt]) > a:
            return True
        else:
            pt += 1
    return False

ans = ""
if judge(N,int(a)):
    a = str(int(a)+1)
for i in range(len(N)):
    ans += a
print(ans)

Solution (Python):
N=int(input())
for i in range(N,N+500,1):
    T=str(i)
    if T[0]==T[1]==T[2]:
        print(i)
        break
    else:
        continue

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

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

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

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

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

Solution (Python):
N=int(input())
M=0
for i in range(999):
  n=str(N+i)
  if n[0]==n[1] and n[1]==n[2]:
    print(n)
    break

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

Solution (Python):
n = input()

if len(set(n)) == 1:
    print(n)
else:
    n = [c for c in n]
    if n[0] < n[1] or n[0] < n[2]:
        n = str(int(n[0])+1)
        print(n*3)
    elif n[0] >= n[1] and n[0] >= n[2]:
        print(n[0]*3)

Solution (Python):
n =int(input())
for i in range(n):
    if i*111 >=n:
        print(111*i)
        break

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

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

while n not in ok:
    n += 1
    
print(n)

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

while not (n%10 == (n//10)%10 == n//100):
    n += 1
    
print(n)

Solution (Python):
a=[111,222,333,444,555,666,777,888,999]
i=0
n=int(input())
while a[i]<n:
    i=i+1
print(a[i])

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

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

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left

def main():
    n = II()
    cc = [111,222,333,444,555,666,777,888,999]
    print(cc[bisect_left(cc, n)])


if __name__ == '__main__':
    main()

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

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


while True:
    if len(set(list(str(n))))==1:
        print(n)
        break
    else:
        n+=1

Solution (Python):
n=input()
nn=n[0]*3
if n<=nn:print(nn)
else:print(chr(ord(n[0])+1)*3)

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

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

Solution (Python):
def Atcoder111(n):

    ans = ""

    if int(n[0]) > int(n[1]) or int(n[0]) == int(n[1]) >= int(n[2]):
        ans = n[0]*3
    else:
        ans = int(n[0]*3)
        ans += 111

    return ans

def main():
    n = str(input())
    print(Atcoder111(n))

if __name__ == '__main__':
    main()

Solution (Python):
a = int(input())
ans_list = []
for i in range(10):
    ans_list.append(111*i)
for i in range(10):
    if a > ans_list[i] and a <= ans_list[i+1]:
        print(ans_list[i+1])

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

res = 0
for i in range(11):
    if i == 10:
        tmp = 1111
    else:
        tmp = i * 111
    if tmp >= N:
        res = tmp
        break
print(res)

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

Solution (Python):
n = int(input())
s = ['111','222','333','444','555','666','777','888','999']
for i in range(n, 1000):
    if str(i) in s:
        print(i)
        break

Solution (Python):
N = input()


def main():

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

    cnt = int(N)
    while True:
        if cnt % 111 == 0:
            print(cnt)
            return
        cnt += 1


main()

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 = input()

hendred = n[0]
jadgeNumString = n[0]*3
jadgeNum = int(jadgeNumString)

if int(n) <= jadgeNum:
    print(jadgeNum)
else:
    print(jadgeNum + 111)

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

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

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

Solution (Python):
a=int(input())
b=a//100
c=(a-b*100)//10
d=a%10
if b<c:
    print((b+1)*111)
elif (b==c)and(b<d):
    print((b+1)*111)
else:
    print(b*111)

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

Solution (Python):
list = [111, 222, 333, 444, 555, 666, 777, 888, 999]

n = int(input())
ans={}
for i in list:
    if i-n>=0:
        ans[i]=(i - n)
print(min(ans))

Solution (Python):
n=int(input())
num=str(n)[0]*3

if n<=int(num):
  print(num)
  
else:
  print(int(num)+111)

Solution (Python):
a=input()


if a[0]==a[1] and a[1]==a[2]:
    print(a)
else:
    while 1:
        a=int(a)
        a+=1
        a=str(a)

        if  a[0]==a[1] and a[1]==a[2]:
            print(a)
            break

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

Solution (Python):
N = int(input())
n = 111
while n < N:
  n += 111
print(n)

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

Solution (Python):

N = int(input())
ans = N
while True:
    if N % 111 == 0:
        ans = N
        print(ans)
        break
    N += 1

Solution (Python):
N = int(input())
if N<=111:
  print(111)
l=111
r=222
for _ in range(8):
  if N>l and N<=r:
    print(r)
  l+=111
  r+=111

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for i in range(1112):
    s = list(str(i))
    t = list(Counter(s).items())
    if len(t) == 1 and i >= n:
        print(i)
        quit()

Solution (Python):
N=int(input())
ans=ju=0
for i in range(0,1000,111):
  if(i>N):
    print(i)
    break
  elif(i==N):
    print(i)
    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)
elif N <= 999:
  print(999)

Solution (Python):

N=int(input())

while True:
  
  if len(set(str(N)))==1:
    print(N)
    break

  
  N+=1

Solution (Python):
N = int(input())
if 100<=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)
else:
  print(999)

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

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


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

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

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

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

for i in range(1000):
    n_str = str(n)
    if n_str[0] == n_str[1] == n_str[2]:
        break
    n += 1

print(n_str)

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

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

Solution (Python):
l = [111,222,333,444,555,666,777,888,999]
n = int(input())
for i in l:
    if i >= n:
        print(i)
        exit()

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

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

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

a=N//100
if N>a*100+a*10+a:
    print((a+1)*100+(a+1)*10+a+1)
else:
    print(a*100+a*10+a)

Solution (Python):

import math
import itertools
import statistics



s = int(input())
ABC =[111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(len(ABC)):
    if s <= ABC[i]:
        print(ABC[i])
        exit()

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

Solution (Python):
n = input()
if len(set(list(n)))==1:
    print(n)
else:
    num = int(n[0])+int(n[0])*10+int(n[0])*100
    if int(n) < num:
        print(num)
    else:
        print(num+111)

Solution (Python):
n = input()
if len(set(list(n)))==1:
    print(n)
else:
    num = int(n[0])+int(n[0])*10+int(n[0])*100
    if int(n) < num:
        print(num)
    else:
        print(num+111)

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

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

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

Solution (Python):
n = int(input())
for i in range(n, 1000):
  if i//100 == (i//10)%10 == i%10:
    print(i)
    break

Solution (Python):
N = int(input())
X = [111, 222, 333, 444, 555, 666, 777, 888, 999]
print(min([i for i in X if i >= N]))

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

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)
       exit()
   else:
       n += 1

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

judge=False

while judge==False:
    base=str(N)[0]
    judge=True
    for n in str(N):
        if n==base:
            pass
        else:
            judge=False
            N+=1
            break
print(N)

Solution (Python):
N=int(input())
for i in range(N,1112):
  str_i=str(i)
  if all(str_i[i]==str_i[0] for i in range(1,len(str_i))):
    print(i)
    break

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

result = 1111
for i in range(1, 10):
    a = i*100 + i*10 + i
    if a >= n:
        result = a
        break

print(result)

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N = int(input())
    while len(Counter(str(N))) != 1:
        N += 1
    print(N)


main()

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

judge = 111
ans = 1000

for i in range(9):
    if judge >= N:
        ans = min(ans,judge-N)  
    judge += 111
    
print(ans+N)

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)
else:
    print(1111)

Solution (Python):
n=int(input())
for i in range(n,999+1):
    s=str(i)
    if s[0]==s[1] and s[1]==s[2]:
        print(i)
        import sys
        sys.exit()

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

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().strip())

xs = [int(str(i) * 3) for i in range(1, 10)]
for x in xs:
    if N <= x:
        print(x)
        break
    else:
        continue

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

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

Solution (Python):



N = int(input())


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

Solution (Python):



N = int(input())


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

Solution (Python):

n = int(input())
for i in range(n, 1000):
    s = str(i)
    if s[0] == s[1] == s[2]:
        print(i)
        exit()

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

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

Solution (Python):
import sys

N = int(input())

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

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

for i in range(N,1000):
  a=str(i)[0]
  b=str(i)[1]
  c=str(i)[2]
  if a==b and b==c:
    print(i)
    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):
N = input()
s = N[0] * 3
if s < N: s = chr(ord(N[0]) + 1) * 3
print(s)

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

Solution (Python):
N = int(input())
def ceil(n): 
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
print(ceil(N/111)*111)

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

while True:
    if len(set([i for i in str(n)])) == 1:
        print(n)
        break
    n += 1

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

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

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

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

l = [100, 10, 1]

n100 =  n // 100
n10 = (n - n100 * 100) // 10
n1 = (n - n100 * 100 - n10 * 10)

if n100 > n10:
    print(int(str(n100) * 3))
elif n100 < n10:
    print(int(str(n100 + 1) * 3))
else:
    if n10 > n1:
        print(int(str(n100) * 3))
    elif n10 < n1:
        print(int(str(n100 + 1) * 3))
    else:
        print(n)

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

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


if __name__ == '__main__':
    main()

Solution (Python):

def ok(n):
    s=str(n)
    for i in range(len(s)):
        if(s[i]!=s[0]):return False
    return True

n=int(input())
while(1):
    if(ok(n)):
        print(n)
        break;exit();
    n+=1

Solution (Python):
n = int(input())
x = 111
for _ in range(10):
    if n <= x:
        print(x)
        exit(0)
    x += 111

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

for i in range(1, 10):
    ans = 100 * i + 10 * i + i
    if ans >= n:
        break

print(ans)

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

while True:
  if len(set(str(N))) == 1:
    print(N)
    break
  N += 1

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

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

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

print(int(s))

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

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

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

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

Solution (Python):
import sys


def main():
    anss = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    n = int(input())
    for ans in anss:
        if ans >= n:
            print(ans)
            sys.exit(0)


if __name__ == "__main__":
    main()

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

while True:
    if len(set(str(N))) == 1:
        print(N)
        exit()
    N += 1