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):
n = int(input())
print((((n-1)//111)+1)*111)

Solution (Python):
S = list(input())
a,b,c = int(S[0]),int(S[1]),int(S[2])
if (a<b or a<c):
  ans = (a+1)*100+(a+1)*10+a+1
else :
  ans = (a)*100+(a)*10+a
print(ans)

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

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

for i in range(111, 1000, 111):
    if n <= i:
        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())
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)
elif 889<=N<=999:
  print(999)

Solution (Python):
a=int(input())
print(a+(a%111!=0)*111-a%111)

Solution (Python):
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")
else:
    print("999")

Solution (Python):
n =int(input())
a = n//100
b= 100*a+10*a+a

if n <=b:
  print(b)
else:
  print(100*(a+1)+10*(a+1)+(a+1))

Solution (Python):
import sys


N = int(input())

for i in range(N, 1000):
    c1 = i // 100
    c2 = (i-c1*100) // 10
    c3 = (i-c1*100-c2*10)
    if c1 == c2 == c3:
        print(i)
        sys.exit()

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

if int(year[0])>=int(year[1]) and int(year[0])>=int(year[2]):
  year[1]=year[0]
  year[2]=year[0]
else:
  temp=int(year[0])+1
  year[0]=str(temp)
  year[1]=str(temp)
  year[2]=str(temp)
year=''.join(year)
print(year)

Solution (Python):
N = int(input())
n = list(filter(lambda x: x >= N, [111*i for i in range(1, 10)]))
print(n[0])

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

Solution (Python):
n = int(input())
i = int(n / 111)

if n % 111 != 0:
  i += 1

print(i * 111)

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

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
ans = 111

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

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

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

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

Solution (Python):
n=str(input())
if n[0] == n[1] and n[1] == n[2]:
    print(n)
else:
    for i in [111,222,333,444,555,666,777,888,999]:
        if int(n) < i:
            print(i)
            quit()

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

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

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

Solution (Python):

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

Solution (Python):

def main():
    N = int(input())
    ans = (N + 110) // 111 * 111
    print(ans)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
nStr = input()
nTopNum = int(nStr[0])
nNum = int(nStr)
print(nNum if nNum % 111 == 0 else nTopNum *
      111 if nTopNum * 111 > nNum else (nTopNum + 1) * 111)

Solution (Python):
nStr = input()
nNum = int(nStr)
if nNum % 111 == 0:
    print(nNum)
else:
    print(int(nStr[0]) * 111 if int(nStr[0])
          * 111 > nNum else (int(nStr[0]) + 1) * 111)

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

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

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

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

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n=int(input())

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

Solution (Python):
import math

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

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

Solution (Python):
a = list(input())
if max(a)==a[0]:
        print(a[0]*3)
elif min(a)==a[0]:
        print((int(a[0])+1)*111)        
elif max(a)==a[1]:
        print((int(a[0])+1)*111) 
elif max(a)==a[2] and a[0]<=a[1]:
        print((int(a[0])+1)*111)               
elif max(a)==a[2] and a[0]>a[1]:
        print(a[0]*3)

Solution (Python):
N = input()
a = int(N[0] * 3)

if int(N) > a:
    a += 111

print(a)

Solution (Python):
n = input()
current = n[0]
flag = False
for i in range(len(n)):
    
    if n[i] != current:
        
        if n[i] > current:
            flag = True
            break
        
        else:
            n = current * 3
            break

if flag:
    x = int(current) + 1
    print(int(str(x) * 3))
else:
    print(n)

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

for i in range(1000):

  d3 = str(n)[0]
  d2 = str(n)[1]
  d1 = str(n)[2]

  if (d1 == d2) and (d2 == d3):
    print(n)
    break
    
  n += 1

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

Solution (Python):
n = int(input())
a = n//100
b = (n-100*a)//10 
c = n-100*a-10*b
if a > b or (a == b and b >= c):
  print(111*a)
else:
  print(111*(a+1))

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

Solution (Python):
N=int(input())
a=N//100
b=(N-a*100)//10
c=N-(a*100)-(b*10)
if (a==b and b>=c) or a>b:
  print(a*100+a*10+a)
else:
  print((a+1)*100+(a+1)*10+a+1)

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

Solution (Python):
N = int(input())
x = (N-1) // 111

print((x+1)*111)

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

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

Solution (Python):
N = int(input())
flag = 0
while flag == 0:
    if N // 100 == (N - N // 100 * 100) // 10 == (N - N // 10 * 10):
        flag += 1
        break
    N += 1
        
print(N)

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

N = input().split()
N = list(N[0])

if int(N[0]+N[0]+N[0]) >= int("".join(N)):
    print(int(N[0]+N[0]+N[0]))
else:
    print(int(N[0]+N[0]+N[0])+111)

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

N = int(input())
out = []
for i in range(1,10):
    out.append(i*100 + i*10 + i)
for i in range(len(out)):
    if out[i] >= N:
        print(out[i])
        exit()

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

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

for i in range(9):
	if l[i]-n>=0:
		print(l[i])
		break

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

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

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

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

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

Solution (Python):

N = int(input())

if N <= 111:
    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):
print(-int(input()) // 111*-111)

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

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

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

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

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

Solution (Python):
"""
【ABC111】
B_AtCoder_Beginner_Contest_111



import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

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

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

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

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

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

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

Solution (Python):
n=int(input())
a=n//100
b=a*100+a*10+a
c=(a+1)*100+(a+1)*10+a+1
if n<=b:
    print(b)
else:
    print(c)

Solution (Python):
n = int(input())
while True:
    if n%10 == n//10%10 == n // 100:
        print(n)
        break
    else:
        n += 1

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

def main():
    N = int(input())
    for i in range(N,1000):
        if i//100 == i//10%10 == i%10:
            print(i)
            return

if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())

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

print(ans)

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

l = [str(i) * 3 for i in range(1, 10)]

for i in l:
    if N <= int(i):
        print(i)
        exit()

Solution (Python):
N = int(input())
L = [int(str(x) * 3) for x in range(1, 10)]

for n in L:
    if N <= n:
        print(n)
        break

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

Solution (Python):
def main():
    N = input()
    tmp = int(N[0])
    if int(N[1]) > tmp:
        print("{}{}{}".format(tmp+1, tmp+1, tmp+1))
    elif int(N[1]) < tmp:
        print("{}{}{}".format(tmp, tmp, tmp))
    else:
        if int(N[2]) > tmp:
            print("{}{}{}".format(tmp+1, tmp+1, tmp+1))
        elif int(N[2]) <= tmp:
            print("{}{}{}".format(tmp, tmp, tmp))

if __name__ == "__main__":
    main()

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
arr = [111 * k for k in range(10)]
for i in range(len(arr) - 1):
    if arr[i] < n <= arr[i+1]:
        print(arr[i+1])
        break

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

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

print(ans)

Solution (Python):
N = input()

c_list = [str(i) * 3 for i in range(1,10)]
ans_list = [int(x)-int(N) for x in c_list]

upper = 999

ans_index = 0
for i,x in enumerate(ans_list):
  if 0 <= x <= upper:
    ans_index = i
    upper = x
    
print(c_list[ans_index])

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

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

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

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

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

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())
ans = 0
for i in range(n, 1000):
    now = str(i)
    if now.count(now[0]) == 3:
        ans = i
        break
print(ans)

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

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

if x <= math.floor(x / 100) * 111:
  print(math.floor(x / 100) * 111)
else:
  print(math.ceil(x / 100) * 111)

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

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

Solution (Python):
n=list(input())
a=n[0]*len(n)
n1=0
for i in range(len(n)):
    n1+=int(n[i])*(10**(len(n)-1-i))
if int(a)<n1:
    n[0]=str(int(n[0])+1)
    print((n[0])*len(n))
else:
    print(a)

Solution (Python):
N = int(input())
print(((N-1)//111+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):
n = int(input())
lst = [111,222,333,444,555,666,777,888,999]
lst.append(n)
newlst = sorted(lst)

print(newlst[newlst.index(n)+1])

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

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

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

Solution (Python):

N=input()
s=int(N[0])
S=3*str(s)
if int(N)>int(S):
    S=str(s+1)*3
print(S)

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

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

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

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

Solution (Python):
n = input()

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

print(n)

Solution (Python):
import sys
n = int(input())
for i in range(9):
    z = str(i+1)*3
    if n<=int(z):
        print(z)
        sys.exit()

Solution (Python):
s1 = input()
n1 = int(s1)
n2 = int(s1[0])

r1 = 0

if n1 <= ((n2 * 100) + (n2 * 10) + n2):
    r1 = (n2 * 100) + (n2 * 10) + n2
else:
    r1 = ((n2 + 1) * 100) + ((n2 + 1) * 10) + n2 + 1

print(r1)

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

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

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

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



main()

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

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

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

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

Solution (Python):


N = int(input())

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

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    while True:
        s = str(N)
        if len(set(list(s))) == 1:
            return int(s)
        else:
            N += 1
    

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

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

x=0
for i in range(N,1000):
    x=str(i)
    if i/int(x[0])==111:
        print(x)
        break

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

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

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

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

for i in l:
  if(v <= i):
    print(i)
    exit()

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

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

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

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

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

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

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

def zorome(n):
	l = []
	while n > 0:
		l.append(n%10)
		n = n//10
	return l

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

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

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

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



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

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

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

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

Solution (Python):
n = input()
flag = False
while flag == False:
    
    for i in range(len(n)-1):
        
        if n[i] != n[i+1]:
            n = str(int(n) + 1)
            break
        

        if i == len(n)-2:
            
            flag = True

print(int(n))

Solution (Python):
n = int(input())
for i in range(0,11):
  low = i * 100 + i *10 + i
  high = (i+1) * 100 + (i+1) *10 + (i+1)
  if low < n and n <= high:
    print(high)
    break

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):
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):
n = int(input())
ans = 0
for i in range(1,10):
    if 111*i>=n:
        ans = 111*i
        break
print(ans)

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

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

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

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


for i in range(n, 1000):
    if solve(str(i)):
        print(i)
        break

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

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

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

for i in range(1,10):
    m = int(str(i)*3)
    if n <= m:
        print(m)
        break

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

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

Solution (Python):
def solve():
    n = int(input())
    while True:
        if len(set(str(n))) == 1:
            return n
        n += 1


if __name__ == "__main__":
    print(solve())

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

Solution (Python):
a,b,c=input()
print(int(a+a+a)) if int(a+a)>=int(b+c) else print(int(str(int(a)+1)*3))

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):
s=input()
x=int(s)
candidate1=int(s[0]+s[0]+s[0])
candidate2=str(int(s[0])+1)+str(int(s[0])+1)+str(int(s[0])+1)
if x <= candidate1:
    print(candidate1)
else:
    print(candidate2)

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

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

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

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

Solution (Python):
num = [int(i) for i in input()]
if num[0] > num[1]:
    print(111*num[0])
elif num[0] == num[1]:
    if num[1] >= num[2]:
        print(111*num[0])
    else:
        print(111 * (num[0] + 1))
else:
    print(111*(num[0]+1))

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

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

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

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

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

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

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

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

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

x = 111
while True:
    if x >= n:
        print(x)
        exit()
    else:
        x += 111

Solution (Python):



N = int(input())


ans = int(N / 111)
if N % 111 != 0:
    ans += 1


print(ans * 111)

Solution (Python):
import math
import copy
import sys

def zorome(num):
    return int(111*num)

inputa = input().split()



a = int(inputa[0])























listNum = list(str(a))

if int(a) <= zorome(int(listNum[0])):
    print(zorome(int(listNum[0])))
else:
    print(zorome(int(listNum[0])+1))

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

import math
print(math.ceil(N / 111)*111)

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

Solution (Python):


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

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

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

Solution (Python):
import sys

N = int(input())

num = (N-1) // 111

print((num+1)*111)

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

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

Solution (Python):

n = int(input())
for n in range(n, 999+1):
    if len(set(list(str(n)))) == 1:
        print(n)
        exit()

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

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

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

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

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

Solution (Python):
n = int(input())
L = [0]*10
for i in range(10):
    L[i] = 111*i
for i in range(10):
    if (n > L[i]) and (n <= L[i+1]):
        print(L[i+1])
        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=int(input())
print((((N-1)//111)+1)*111)

Solution (Python):
n=int(input())
d=int((n-1)/111)+1
print(*[d,d,d],sep='')

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

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

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

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

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

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

l = [i * 111 for i in range(1, 10)]
for i in l:
    if N <= i:
        print(i)
        exit()

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

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

Solution (Python):
n = input()
f = int(n[0])
s = int(n[1])
t = int(n[2])
if f < s:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
elif f > s:
    ans = f*100 + f*10 + f
elif f == s and f >= t:
    ans = f*100 + f*10 + f
else:
    ans = (f+1)*100+ (f+1)*10+ (f+1)
print(ans)

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

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

Solution (Python):
n=input()
g=n[0]
h=str(int(n[0])+1)
ni=int(n)
if ni <= int(g+g+g):
    print(g+g+g)
else:
    print(h+h+h)

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

if n <= 111:
    print(111)
    exit()

for i in range(111, 1000, 111):
    if i < n and n <= i + 111:
        print(i + 111)

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

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

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

Solution (Python):
N = input()
n = int(N)//100
if N[0]==N[1]==N[2]:
    print(N)
elif N[0]==N[1] and N[0]>N[2]:
    print(100*n+10*n+n)
elif N[0]>N[1]:
    print(100*n+10*n+n)
else:
    n = n+1
    print(100*n+10*n+n)

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

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

ans = 0
for i in range(s, 1000):
    if check_target(i):
        ans = i
        break

print(ans)

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

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

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

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

for i,v in enumerate(ABC):
    tmp = v - N
    if tmp >= 0:
        print(v)
        break

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

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

Solution (Python):
n = int(input())
x = str(n)
while True:
  digit = len(x)
  for i in range(digit):
    if x[i] != x[0]:
      break
  else:
    print(x)
    break
  y = int(x)
  y += 1
  x = str(y)

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())
t = n//100
t*=111
if t>=n:
  print(t)
else:
  print(t+111)

Solution (Python):
n = int(input())
candidates = [111 * i for i in range(1, 10)]
for candidate in candidates:
    if n <= candidate:
        print(candidate)
        exit()

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

def main():
	n = int(input().strip())
	d = (n + 111 - 1) //111
	print(111 * d)

if __name__ == '__main__':
	main()

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

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

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

print(((N + 110) // 111) * 111 )

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

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

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

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

n100 = 0
n10 = 0
n1 = 0


while 1:
    n100 = n//100
    n10 = (n-n100*100)//10
    n1 = (n-n100*100-n10*10)
    if (n100 == n10) and (n10==n1):
        print(n)        
        break
    if n>= 1000:
        break
    n+=1

Solution (Python):
strN = input()
n = int(strN)
for i in range(n,n + 111):
    if i % 111 == 0:
        print(i)
        exit()

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

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

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

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

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N] = string_to_int(inputs[0])
    i = N
    while 1:
        i_str = str(i)
        prev = i_str[0]
        is_ok = True
        for c in i_str:
            if c != prev:
                is_ok = False
                break
        if is_ok:
            return i
        i += 1


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
n = input()
while n.count(n[0]) != 3:
    n = int(n)
    n += 1
    n = str(n)
print(n)

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

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

Solution (Python):
n = list((input()))
pred = n[0]*3
if pred == (''.join(n)) or int(pred) >= int(''.join(n)):
  print(pred)
elif int(pred) <= int(''.join(n)):
  print(int(pred)+111)

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

Solution (Python):
a = int(input())
while True:
    if a % 111 == 0:
        print(a)
        exit()
    else:
        a += 1

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

Solution (Python):

def main():


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

    print(int(''.join(list(str(int(N/111)+1))*3)))





if __name__== "__main__":
    main()

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

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

n = N
flag = True
while flag:
    s = str(n)
    s0 = s[0]
    for si in s:
        flag = True
        if si != s0:
            break
        flag = False
    n += 1

print(n - 1)