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

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = S()
    for i in n:
        if i == "1":
            print(9,end = "")
        else:
            print(1,end = "")
    print()

def B():
    n = I()
    for i in range(n,1000):
        if i%111 == 0:
            print(i)
            quit()
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    B()

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

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

Solution (Python):
N=int(input())
X=P=0
for i in range(10) :
  P=i*111
  if X < N and N <= P :
    print(P)
  X=P

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

for i in range(N, 1000):
    xs = set()
    n = i
    while n > 0:
        xs.add(n % 10)
        n //= 10
    if len(xs) == 1:
        ans = i
        break

print(ans)

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

Solution (Python):


n = list(input())
kouho1 = n[0] * len(n)
kouho2 = str(int(n[0]) + 1) * len(n)

m = "".join(n)

if int(kouho1) >= int(m):
    print(kouho1)
else:
    print(kouho2)

Solution (Python):
n=int(input())
if n%111==0:
    print(n)
else:
    print((n//111)*111+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)
elif N <= 999:
  print(999)

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

def main():
    for n in range(N, 1000):
        if len(set(str(n))) == 1:
            return n

if __name__ == '__main__':
    print(main())

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

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

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

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

Solution (Python):
import sys

n = int(input())

while True:
    if n % 111 == 0:
        print(n)
        sys.exit()
    n += 1

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())
ans = 1000
for i in range(1,10):
    if ((i*100+i*10+i)-N)>=0:
        ans = min(ans, i*100+i*10+i)
print(ans)

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

Solution (Python):
N = str(input())
m0 = int(N[0])
m1 = int(N[0]) + 1
M0 = 100*m0 + 10*m0 + m0
M1 = 100*m1 + 10*m1 + m1
if int(N[1])<=int(N[0]) and int(N[2])<=int(N[0]):
    print(M0)
else:
    print(M1)

Solution (Python):
N = int(input())
a = [str(i)*3 for i in range(1,10)]
print(a[(N-1)//111])

Solution (Python):
n = int(input())
for i in range(1000):
    if n + i == 111 or n + i == 222 or n + i == 333 or n + i == 444 or n + i == 555 or n + i == 666 or n + i == 777 or n + i == 888 or n + i == 999:
        print(n+i)
        exit()

Solution (Python):
n = input()

for i in range(10):
    if int(str(i)*3) >= int(n):
        print(str(i)*3)
        exit()

Solution (Python):
N = int(input())
a = N//111
if(N%111==0):
    print(N)
else:
    print((a+1)*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):
T=int(input())
TT=T//100
if T<=TT*111:
  print(TT*111)
else:
  print((TT+1)*111)

Solution (Python):


N = int(input())
strN = list(str(N))
a = int(strN[0]*3)
if N > a:
    ans = str(int(strN[0])+1)*3
else:
    ans = a

print(ans)

Solution (Python):
import numpy as np

n=int(input())

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

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

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

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

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

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

Solution (Python):
N = input()
if int(N) <= 111:
    print(111)
else:
    for m in range(0, 9):
        left = 112 + 111*m
        right = 222 + 111*m
        if (left<=int(N))&(int(N)<=right):
            print(right)
            break

Solution (Python):
from sys import stdin
n=int(stdin.readline().rstrip())
l=[111*i for i in range(1,10)]
for i in l:
    if n <= i:
        print(i)
        break
    else:
        pass

Solution (Python):
n = input()
if int(n[0]) >= int(n[1]) and int(n[0]) >= 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())

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

Solution (Python):
def calc(n):
    a_list = []
    a = 0
    for i in range(0, n+1):
        a += 10**i
        a_list.append(a)
    return a_list
n = int(input())
N = len(list(str(n)))
a_list = calc(N+1)
b_list = []
for i in range(1, 10):
    for a in a_list:
        b_list.append(a * i)
b_list = sorted(b_list)
print([b for b in b_list if b >= n][0])

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

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

Solution (Python):
s = input()

target = int(s[0]) * 111
if int(s) <= target:
  print(target)
else:
  print(target+111)

Solution (Python):
data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
elif int(data[0]) == int(data[1]):
    if int(data[1]) > int(data[2]):
        sc = int(data[0])
        ans = sc * 100 + sc * 10 + sc
        print(ans)
    else :
        sc = int(data[0]) + 1
        ans = 100* sc + 10 * sc + sc
        print(ans)


        
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)

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

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

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

for i in ABC:
    if N <= i:
        break

print(i)

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

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

    first = int(N / 100)

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

main111()

Solution (Python):
N=int(input())
list=[111,222,333,444,555,666,777,888,999]
for i in list:
    if i>=N:
        print(str(i))
        break;
    else:
        pass;

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

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

Solution (Python):


n=int(input())
ans=0

for i in range(n,n+1000):
    
    a=str(i)
    flag=1

    for j in range(len(a)):
        if(a[0]!=a[j]):
            flag=0
    if(flag==1):
        ans=a
        break
        
print(ans)

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

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

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

Solution (Python):
N = input()
N0 = int(N)
N1 = list(N)
N2 = int(N1[0]+N1[0]+N1[0])

if(N0 <= N2):
  print(N2)
else:
  print(N2+111)

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

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

Solution (Python):
A = input()
AAA = int(A[0]*3)
if AAA >= int(A):
  print(AAA)
else:
  print(AAA + 111)

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

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())
a=(n-1)/111
b=(a+1)//1
print(int(100*b+10*b+b))

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

Solution (Python):
N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,10))
y=list(t for t in x if t>=N)
print(min(y))

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

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

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

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

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

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

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

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

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

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

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

    result = 0
    if 0 <= N <= 111:
        result = 111
    elif 111 < N <= 222:
        result = 222
    elif 222 < N <= 333:
        result = 333
    elif 333 < N <= 444:
        result = 444
    elif 444 < N <= 555:
        result = 555
    elif 555 < N <= 666:
        result = 666
    elif 666 < N <= 777:
        result = 777
    elif 777 < N <= 888:
        result = 888
    elif 888 < N <= 999:
        result = 999

    print(result)
    

main()

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

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

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

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

else:
    print(str(int(N[0]) + 1) * 3)

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

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

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

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

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

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

Solution (Python):
import bisect
N = int(input())
candidate = [int(i*111) for i in range(1,10)]
print(candidate[bisect.bisect_left(candidate, N)])

Solution (Python):
N=int(input())
c=[111*i for i in range(10)]
for _ in c:
    if N <= _:
        print(_)
        break

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

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

def check(n):
  s=str(n)
  for i in range(1,len(s)):
    if s[i] != s[i-1]:
      return False
  return True

while True:
  if check(N):
    print(N)
    break
  else:
    N+=1

Solution (Python):
def abc111(N: int) -> int:
    d = N // 100
    n1 = d * 111
    n2 = (d+1) * 111

    if N <= n1:
        return n1
    return n2


if __name__ == "__main__":
    N = int(input())
    ans = abc111(N)
    print(ans)

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

ans = [111,222,333,444,555,666,777,888,999]
import bisect
N = ri()
i = bisect.bisect_left(ans,N)
print(ans[i])

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

Solution (Python):
n=int(input())
for i in range(n, 2000):
    l=list(str(i))
    if all (j==l[0] for j in l):
        print(i)
        break

Solution (Python):

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

Solution (Python):
N = input()
N_list = [int(i) for i in N]
top_num = N_list[0]
length = len(N_list)
flag = True
for i in range(length-1):
  if top_num == 9:
    flag = True
    break
  if N_list[i]>N_list[i+1]:
    flag = True
    break
  elif N_list[i]==N_list[i+1]:
    flag = True
  else:
    flag = False
    break

if flag:
  print(str(top_num)*length)
else:
  print(str(top_num+1)*length)

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

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

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


if __name__ == "__main__":
    main()

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

ansers = [i * 111 for i in range(1, 10)]

ret = 999
for a in ansers:
    if N <= a:
        ret = a
        break

print(ret)

Solution (Python):
strn = input()
n = int(strn)
head = strn[0]
if(n <= int(head*len(strn))):
    print(int(head*len(strn)))
elif(int(head) <= 8):
    print(int(str(int(head)+1)*len(strn)))
else:
    print(int("1"*(len(strn)+1)))

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

if a > b:
  print(a*111)
elif a == b:
  if b >= c:
    print(a*111)
  else:
    print((a+1)*111)
else:
  print((a+1)*111)

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

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

l = []

for i in range(1,10):
	l.append(i*111)

l.append(0)
l.sort()

for i in range(9):
	if l[i] < n <= l[i+1]:
		print(l[i+1])

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

Solution (Python):
from sys import stdin
N=int(stdin.readline().rstrip())
ans=0
tmp=1000
for i in range(1,10):
    for j in range(3,5):
        num=int(str(i)*j)
        if num-N >= 0 and tmp > num-N:
            tmp = num-N
            ans=num
print(ans)

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

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

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

Solution (Python):


N = int(input())

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

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

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

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

Solution (Python):


N = int(input())

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

Solution (Python):
def solve(string):
    if int(string[0]) == int(string[1]) == int(string[2]):
        return string
    elif int(string[0] * 3) > int(string):
        return string[0] * 3
    else:
        return str(int(string[0]) + 1) * 3


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):






N = int(input())





if str(N)[0] > str(N)[1]:
    tmp = str(N)[0]
elif str(N)[0] == str(N)[1]:
    if str(N)[1] >= str(N)[2]:
        tmp = str(N)[0]
    else:
        tmp = str(int(str(N)[0]) + 1)
else:
    tmp = str(int(str(N)[0]) + 1)





print(int("".join([tmp for _ in range(3)])))

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

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

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

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

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

N = int(input())
arr = [111,222,333,444,555,666,777,888,999]
tgt = [N-111*(i+1) for i in range(9)]
for i,sub in enumerate(tgt):
  if sub <= 0:
    print(arr[i])
    break

Solution (Python):
N = int(input())
ABC = [int("{0}{0}{0}".format(i)) for i in range(10)]
for abc in ABC:
  if N <= abc:
    print(abc)
    break

Solution (Python):


N = int(input())

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

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

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

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

Solution (Python):
N = input()

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

Solution (Python):
N = input()
n= int(N)
while(n<=999):
    ans = n
    if len(set(str(n))) == 1:
        break
    else:
        n += 1
print(n)

Solution (Python):
N=int(input())
a = N//100*100+N//100*10+N//100
b = (N//100+1)*100+(N//100+1)*10+(N//100+1)
print(a*(N<=a)+b*(N>a))

Solution (Python):
N = input()
  
for d in range(1, 10):
  if str(d) * len(N) >= N:
    print(str(d) * len(N))
    break

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

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

Solution (Python):
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[1]))):
    ans = int(a[0] * 3)
elif(int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]) and a[-1] != '0'):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

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

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

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

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

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

Solution (Python):
n = int(input())
li = [111,222,333,444,555,666,777,888,999]
nn = []
for i in range(len(li)):
  if li[i] - n >= 0:
    nn.append(li[i]-n)
  else:
    nn.append(1000)
  
print(li[nn.index(min(nn))])

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

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

    for i in range(1, 10):
        a = 111 * i
        if a >= N:
            return a

ans = main()
print(ans)

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

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

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 



ls = [2222,1111,999,888,777,666,555,444,333,222,111]

X = int(input())
ans = 111
for s in ls:
    if X <= s:
        ans = s

print(ans)

Solution (Python):
n=list(input())
if max(n)==n[0]:
    print(n[0]*len(n))
else:
    print(str((int(n[0])+1))*len(n))

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

for index,item in enumerate(s):
    if n <= item:
        print(item,end='')
        break

Solution (Python):


N = int(input())

i = 1
while True:
    v = i * 100 + i * 10 + i
    if N <= v:
        print(v)
        break
    i += 1

Solution (Python):
a = list(map(int, list(input())))
print([str(a[0])*3, str(a[0]+1)*3][a[0] < a[1] or a[0] < a[2]])

Solution (Python):


import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline











ans_st = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = int(input().rstrip())
i = 0
while n > ans_st[i]:
	i += 1
print(ans_st[i])

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

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

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

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

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

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

Solution (Python):
n = input()

start = n[0]

if all([start >= i for i in n]):
    print(n[0] * len(n))
else:
    print((str(int(n[0]) + 1)) * len(n))

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

a = 1
while True:
    b = 111 * a
    if n <= b:
        print(b)
        break
    a += 1

Solution (Python):
n = input()

a = n[0] + n[0] + n[0]
b = str(int(n[0]) + 1)
c = b + b + b

if int(n) <= int(a):
    print(a)
else:
    print(c)

Solution (Python):
N = input()
ans = []
for i in range(len(N)):
  ans.append(N[0])
if int(''.join(ans)) >= int(N):
    print(''.join(ans))
    exit()
ans = []
for i in range(len(N)):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))

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

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

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

while True:
    if N%111==0:
        break
    N=N+1

print(N)

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

for i in '123456789':
    if int(i+i+i) >= N:
        print(i+i+i)
        break

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

for i in range(N,999+1):
    n = list(str(i))
    if n.count(n[0]) == 3:
        print(i)
        break

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

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

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

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

for i in range(9):
    if(N>=111*i and N<=111*(i+1)):
        print(111*(i+1))
        break

Solution (Python):

N = int(input())
result = ''

for i in range(9):
    if 111 * i < N <= 111 * (i+1):
        print(111*(i+1))
        break

Solution (Python):
def main() -> None:
    n = int(input())
    for i in range(n, 1000):
        a,b,c = map(str, str(i))
        if a==b and b==c:
            print("{}".format(i))
            break


if __name__ == '__main__':
    main()

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

while True:
    s = str(N)
    if s[0] == s[1] == s[2]:
        ans = N
        break
    N += 1

print(ans)

Solution (Python):
n = int(input())
while True:
    for i in range(len(str(n))-1):
        if not str(n)[i]==str(n)[i+1]:
            break
        if i==len(str(n))-2:
            print(n)
            import sys
            sys.exit()
    n += 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 = list(input())
a = int(str(n[0])+str(n[1]))
b = int(str(n[1])+str(n[2]))

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

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

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N = str(input().strip())
  L = len(N)
  f = N[0]
  a = f * L
  b = str(int(f) + 1) * L
  
  if int(a) >= int(N):
    print(int(a))
  else:
    print(int(b))


if __name__ == '__main__':
  main()

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

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

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

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

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

Solution (Python):
N = int(input())
zoro = []
for i in range(1, 4):
    for j in range(1, 10):
        string = str(j) * i
        zoro.append(string)
zoro.append("1111")

candidate = [i for i in zoro if int(i) >= N]
print(candidate[0])

Solution (Python):
n=int(input())
for count in range(10):
    if 100*count+10*count+count>n-1:
        print(100*count+10*count+count)
        break
    else:
        pass

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

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

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

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

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

for i in range(9):
    if n <= (i + 1) * 111:
        print((i + 1) * 111)
        break
    else:
        continue

Solution (Python):


















def inpl(): return list(map(int, input().split()))


N = int(input())

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

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

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

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

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

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

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

Solution (Python):
import sys

n = int(input())

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

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

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

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

Solution (Python):
n = list(input())
n_ = [int(x) for x in n]
num = max(n_)
if n_[0] < num:
  n = [n_[0] + 1 for x in n_]
else:
  n = [num for x in n_]

n = [str(x) for x in n]

print(int(''.join(n)))

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

while 1:
    if n%111:
        n+=1
    else:
        print(n)
        break

Solution (Python):
a = input()

l = []
for i in range(len(a)):
    l.append(a[i])

if l.index(max(l)) == 0:
    for _ in range(len(l)):
        print(l[0],end='')
else:
    for _ in range(len(l)):
        print(int(l[0])+1,end='')

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

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

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

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

Solution (Python):
N=int(input())
a=N//100
b=N-a*100
if(b>(11*a)):
  print(111*(a+1))
else:print(111*a)

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

if(A<=111):
    print("111")
elif(A<=222):
        print("222")
elif(A<=333):
    print("333")
elif(A<=444):
    print("444")
elif(A<=555):
    print("555")
elif(A<=666):
    print("666")
elif(A<=777):
    print("777")
elif(A<=888):
    print("888")
else:
    print("999")

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

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