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())
if n%111 == 0:
    print(n)
else:
    a = int(n//111+1)
    print(a*100+a*10+a)

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

Solution (Python):


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

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


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
 
for i in range(N, 1000):
  string = list(str(i))
  flag = 0
  for s in string:
    if s != string[0]:
      flag = 1
  if flag == 0:
    answer = i
    break
 
print(answer)

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

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

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
while True:
    n_str = sorted(str(N))
    if n_str[0] == n_str[-1]:
        break
    N += 1
print(N)

Solution (Python):
""" AtCoder """

import sys
input = sys.stdin.readline

N = int(input())

if N == 999:
    ans = "9"
else:
    ans = str(int((N-1)/111)+1)

print(ans+ans+ans)

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=str(input())
Comp=[]
for i in range(3):
    Comp.append(int(N[i]))
if Comp[0]-Comp[1]<0:
    A=Comp[0]+1
if Comp[0]-Comp[1]>0:
    A=Comp[0]
if Comp[0]-Comp[1]==0:
    if Comp[1]-Comp[2]<0:
        A=Comp[1]+1
    else:
        A=Comp[1]
for i in range(3):
    print(A,end='')

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

for a in A:
    if n <= a:
        print(a)
        break

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

if 100<=n<=111:
  print(111)
if 111<n<=222:
  print(222)
if 222<n<=333:
  print(333)
if 333<n<=444:
  print(444)
if 444<n<=555:
  print(555)
if 555<n<=666:
  print(666)
if 666<n<=777:
  print(777)
if 777<n<=888:
  print(888)
if 888<n<=999:
  print(999)

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

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):
def main():
    N = input()
    for i in range(10):
        n = int(str(i) * len(N))
        if n >= int(N):
            print(n)
            break


main()

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

Solution (Python):


def main():
    n = int(input())
    for i in range(100000):
        x = n + i
        se = set(list(str(x)))
        if len(se) == 1:
            print(x)
            return

main()

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

Solution (Python):

n = int(input());

i = int(n/100)
next_n = 100*i + 10*i + i
if ( n <= next_n ):
    print(next_n)
else:
    print(next_n + 111)

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

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

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

Solution (Python):
def abc(lst:list)->str:
    if lst[0]<lst[1]or lst[0]==lst[1]<lst[2]:
        return (lst[0]+1)*111
    else:
        return lst[0]*111
lst=list(map(int,list(input())))
print(abc(lst))

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

for i in a:
    if i >= N:
        print(i)
        exit()

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

Solution (Python):
N = int(input())
q, mod = divmod(N, 111)
print((q+int(mod>0))*111)

Solution (Python):

def triple(n): return n*100 + n*10 + n

N = int(input())
n = triple(N//100)

if n<N: n = triple(N//100+1)
print(n)

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

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

Solution (Python):
N = input()

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

Solution (Python):
def notOk(x):
    s = x % 10
    x //= 10
    while x > 0:
        if(s != x % 10):
            return 1
        x //= 10
    return 0

n = int(input())
while(notOk(n)):
    n += 1
print(n)

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

Solution (Python):
N = input()
N0 = int(N[0])
N1 = int(N[1])
N2 = int(N[2])

if N0 > N1 or (N0 == N1 and N2 <= N0):
    answer = str(N0)*3
    print(answer)
else:
    N0 = N0 + 1
    answer = str(N0)*3
    print(answer)

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

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

for i in lst:
    if n <= i:
        print(i)
        break

Solution (Python):
def main():
    n = int(input())
    contests = []
    for i in range(1, 10):
        contests.append(100 * i + 10 * i + 1 * i)

    for c in contests:
        if c >= n:
            print(c)
            break


if __name__ == '__main__':
    main()

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

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

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

for rep in repdigit:
    if N <= rep:
        print(rep)
        break

Solution (Python):
n = input()
while not n[0] == n[1] == n[2]:
    n = str(int(n) + 1)
print(n)

Solution (Python):
L=[111,222,333,444,555,666,777,888,999]
N=int(input())
M=[L[i]-N for i in range(len(L))]
O=[M[j] for j in range (len(M)) if M[j]>=0]
a=O[0]
num=M.index(a)
print(L[num])

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

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())
zorome = [0,111,222,333,444,555,666,777,888,999]
diff = [0]*10
for i in range(len(zorome)):
    if zorome[i] == N:
        print(zorome[i])
        break
    elif zorome[i] > N:
        print(zorome[i])
        break

Solution (Python):
N = int(input())
A = [999, 888, 777, 666, 555, 444, 333, 222, 111]
print(list(filter(lambda x: x >= N, A))[-1])

Solution (Python):
N = int(input())
for i in range(N, 1000):
    l = list(str(i))
    if l.count(l[0]) == 3:
        print(i)
        break

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

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

Solution (Python):
N = int(input())
if N == 0:
    N += 1
q, mod = divmod(N, 111)
if mod == 0:
    print(q*111)
else:
    print((q+1)*111)

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

for i in range(N, 1000):
    n = i % 10
    nn = (i % 100) // 10
    nnn = (i % 1000) // 100
    if n == nn and nn == nnn:
        print(i)
        break

Solution (Python):
N=input()

if N%100<=N/100*11:
    print (N/100)*111
else:
    print (N/100+1)*111

Solution (Python):
def piyo():
    n = int(input())
    hoge = n//100
    if int(str(hoge)+str(hoge))>=n%100:
        a = int(str(hoge)+str(hoge)+str(hoge))
    else:
        hoge+=1
        a = int(str(hoge)+str(hoge)+str(hoge))
    print(a)

if __name__ == '__main__':
    piyo()

Solution (Python):



def main():
    """Function."""
    n = int(input())

    nums = []
    for i in range(1, 10):
        nums.append(int(str(i)*3))

    if n == 999:
        print(999)
    else:
        for i in range(len(nums)):
            if n <= nums[i]:
                print(nums[i])
                break


if __name__ == "__main__":
    main()

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

x = 1000

for i in range(x):
    if (N+i)//100 == ((N+i)%100)//10 == (N+i)%10:
        print(N+i)
        break

Solution (Python):
N = int(input())
i = 1
while i < 10:
    if 100 * i + 10 * i + i >= N:
        print(100 * i + 10 * i + i)
        break
    i += 1

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

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

A = N/111
B = N%111

if B == 0:
    C = int(A)
    print(int(100*A+10*A+A))
else:
    C = int(A + 1)
    print(int(100*C+10*C+C))

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
MAX = 1000
for i in range(N, MAX):
    digit = str(i // 100)
    if all(x == digit for x in str(i)):
        print(i)
        break

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

Solution (Python):
N = input()
for i in range(10):
    if int(N[0]) == i:
        if int(N[1]) > i:
            ans = str(i+1)
        if int(N[1]) == i:
            if int(N[2]) > i:
                ans = str(i+1)
            else:
                ans = str(i)
        if int(N[1]) < i:
            ans = str(i)
print(int(ans+ans+ans))

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

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

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

Solution (Python):
n = input()

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

Solution (Python):
N=int(input())
a=[111*i for i in range(1,10)]
ans=0
for i in range(9):
    if N<=a[i]:
        ans=a[i]
        break
print(ans)

Solution (Python):
a = input()
b = list(a)
k = int(''.join([b[0] for _ in range(len(b))]))
if k >= int(a):
    print(k)
else:
    if b[0] != '9':
        print(int(''.join([str(int(b[0]) + 1) for _ in range(len(b))])))
    else:
        print(int(''.join(['1' for _ in range(len(b)+1)])))

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

if n%111==0:
  ans=n
else:
  while n%111>0:
    n+=1
    ans=n
    
print(ans)

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              






a =0
while a < x:
    a+=111
print(a)

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

Solution (Python):
s = input()
n = len(s)
ss = int(s)
i = ss//(10**(n-1))
def cal(k):
    res = int(k)*(10**(n-1))+ int(k)*(10**(n-2))+int(k)*(n-2)
    return res

if cal(i)<ss:
    print(cal(i+1))
else:
    print(cal(i))

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

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

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

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

while(True):
    if n <= a:
        print(a)
        break
    else:
        a += 111

Solution (Python):
s = int(input())
for i in range(1, 10):
    t = str(i) * 3
    if int(t) >= s:
        print(t)
        exit()

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

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue

Solution (Python):
num = str(input())
a = []
x=[]
for i in str(num):
    a.append(i)
if a[1] <= a[0] and a[2] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[1] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[0] == a[1] == a[2]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
else:
    z = int (a[0]) +1
    x.append(z)
    x.append(z)
    x.append(z)
    print(''.join(str(i) for i in x))

Solution (Python):
num = str(input())
a = []
x=[]
for i in str(num):
    a.append(i)
if a[1] <= a[0] and a[2] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[1] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[0] == a[1] == a[2]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
else:
    z = int (a[0]) +1
    x.append(z)
    x.append(z)
    x.append(z)
    print(''.join(str(i) for i in x))

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

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

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

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

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 n in [111*c for c in range(1,10)]:
    if n < N:
        continue
    else:
        print(n)
        break

Solution (Python):
N = int(input())
 
x = 0
for n in [111*c for c in range(1,10)]:
    if n < N:
        continue
    else:
        x = n
        break
print(x)

Solution (Python):
N = int(input())
 
list = [111*c for c in range(1,10)]
list.sort()
 
x = 0
for n in list:
    if n < N:
        continue
    else:
        x = n
        break
print(x)

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

list = [111*int(c) for c in '123456789']
list.sort()

x = 0
for number in list:
    if number < int(N):
        continue
    else:
        x = number
        break
print(x)

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

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

Solution (Python):
n=int(input())
cnt=0
lst=[0,0,0]
while n!=0:
    lst[cnt]=n%10
    n=n//10
    cnt+=1
if lst[2]>lst[1]:
    for i in range(cnt):
        print(lst[2],end="")
elif  lst[2]==lst[1]:
    if lst[1]>=lst[0]:
        for i in range(cnt):
            print(lst[2], end="")
    else:
        for i in range(cnt):
            print(lst[2]+1, end="")
else:
    for i in range(cnt):
        print(lst[2]+1,end="")

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

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

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

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

if x[1]*10+x[2]>x[0]*11:
	print ((x[0]+1)*111)
else:
	print (x[0]*111)

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

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

Solution (Python):

N = int(input())
while N % 111 != 0:
  N = N+1
else:
  print(N)

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

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

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

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

Solution (Python):

N = int(input())




    
def ok(num):
    nmst = "{0:d}".format(num)
    
    if len(nmst) == len(list(filter(lambda x:x==nmst[0], nmst[:]))):
        return True
    else:
        
        
        
        
        
        
        
        return False

for i in range(N, int(1e9)):
    if ok(i):
        print(i)
        exit(0)

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

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

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

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

Solution (Python):


N=int(input())

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

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

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

Solution (Python):
n = int(input())
i = n
while True:
    if str(i).count(str(i)[0])==len(str(i)):
        break
    else:
        i += 1
print(i)

Solution (Python):
s = input()
top = s[0]
ng = False
for i in s:
    if top != i:
        ng = True
        break

if not (ng):
    print(s)
else:
    if int(top * len(s)) < int(s):
        print(str(int(top) + 1) * len(s))
    else:
        print(int(top * len(s)))

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

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

Solution (Python):
n=str(input())
k=True
kaku=n[0]
for i in n:
    if int(n[0])!=int(i):
        k=False
if k:
    print(n)
else:
    if int(n[0])>=int(n[1]) and int(n[0])>=int(n[2]):
        print(n[0]*3)
    else:
        s=int(n[0])+1
        print(str(s)*3)

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

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

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

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

Solution (Python):
n=int(input())
length=len(str(n))

if int(str(n)[0])>= int(str(n)[-1]) and int(str(n)[0])>= int(str(n)[1]):
  print((str(n)[0])*length)
else:
  print(str((int(str(n)[0]))+1)*length)

Solution (Python):
n = input()

t = int(n[0])
th = t*100+t*10+t

if th >= int(n) :
    print(th)
else :
    t = t+1
    th = t*100+t*10+t
    print(th)

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

Solution (Python):
N = int(input())
for n in range(N,1000):
    str_n = str(n)
    first_keta = str_n[0]
    for keta in str_n:
        if keta == first_keta:
            continue
        break

    else:
        print(first_keta * 3)
        exit()

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

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

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

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

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

sys.setrecursionlimit(10**5)

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


n = ni()

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

Solution (Python):
n = input()

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

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

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


print(abc111_b())

Solution (Python):

N = int(input())

num = list(map(int, str(N)))

if num[0] >= num[1] and num[0] >= num[2]:
    print(num[0] * 111)
else:
    print((num[0] + 1) * 111)

Solution (Python):

from sys import stdin

s_in = lambda: stdin.readline()[:-1]  


N = list(s_in())
if N[0] == N[1] and N[1] == N[2]:
    print(''.join(N))
else:
    if int(N[0]) > int(N[1]):
        x = int(N[0])
    elif int(N[0]) < int(N[1]):
        x = int(N[0]) + 1
    elif int(N[1]) >= int(N[2]):
        x = int(N[0])
    else:
        x = int(N[0]) + 1
    print(x * 111)

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

Solution (Python):
s = input()
if int(s) > int(s[0] + s[0] + s[0]):
    if s[0] == '9':
        print(1111)
    else:
        print(str(int(s[0])+1) + str(int(s[0])+1) + str(int(s[0])+1))
else:
    print(s[0] + s[0] + s[0])

Solution (Python):
def solution(s):
    n = len(s)
    k = s[0]
    for i in xrange(1, n):
        if s[i] > k:
            return chr(ord(k) + 1) * n
    return k * n

def main():
    d = int(raw_input().strip())
    print solution(str(d))

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
h=n//100
t=(n%100)//10
o=n%10

while True:
 if h * 111 >= n:
     print(h * 111)
     break
 h+=1

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

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

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

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):
def main():
    n = int(input())

    while True:
        hund = n // 100
        ten = (n % 100) // 10
        one = n % 10
        if hund == ten and hund == one:
            print(n)
            break
        else:
            n += 1

if __name__ == "__main__":
    main()

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

Solution (Python):
n = input()
l=len(n)
s1=str(n[0]*l)
s2=""
if n[0]=='9':
    s2="1"*(l+1)
else:
    s2=str(int(n[0])+1)*l

if n<=s1:
    print(s1)
else:
    print(s2)

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

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

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

for x in abc:
    if n <= x:
        print(x)
        break

Solution (Python):


import math


def solve():
    i = int(input())
    print(math.ceil(i / 111) * 111)


if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())
while True:
    s = str(n)
    if len(s) == s.count(s[0]):
        break
    n += 1
print(n)

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

while True:
    if x[0] == x[1] == x[2]:
        print(x)
        break

    x = str(int(x) + 1)

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

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

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

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

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

for temp in candidate:
    if temp >= N:
        print(temp)
        break

Solution (Python):
s=(int)(input())
n = str(s//100)
if s >(int)(n*3):
    print(str((int)(n)+1)*3)
else:
    print(str(n*3))

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

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

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

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

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

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

Solution (Python):

N = int(input())

out_str = ""
for i in range(10) :
	if (111 * i < N and N <= 111 * (i + 1)):
		out_str = str(111*(i+1))

print(out_str)

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    for i in range(1,10):
        if n <= i*111:
            return i*111

    return -1


print(main())

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

Solution (Python):
a = input()
b = list(a)
c = b[0] + b[0] + b[0]

if int(a) > int(c):
  print(int(c)+111)
else:
  print(int(c))

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

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

ini = int(Nstr[0])

if ( ini*100+ini*10+ini<N ):
  ini+=1
  
print(ini*100+ini*10+ini)

Solution (Python):
N = int(input())
ans = ''
for i in range(N, 1000):
    if not(ans):
        for ch in str(i):
            if str(i).replace(ch, '') == '':
                ans = str(i)
                break
    else: break

print(ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b

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


if __name__ == '__main__':
    main()

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

result = 999
for i in range(len(t)):
    if n <= t[i]:
        result = t[i]
        break

print(result)

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

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

Solution (Python):

import math
num=int(input())


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

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

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

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

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

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

for num in nums:
    if num >= n:
        print(num)
        break

Solution (Python):
import sys


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


main()

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

Solution (Python):
'''
問題文
 黒橋君は，AtCoder Beginner Contest (ABC) にまだ参加したことがありません．
 次に行われる ABC は第 N 回です． 黒橋君は，初めて参加する ABC を第 x 回としたときに，
	x の十進法表記でのすべての桁の数字が同じであるようにしたいです．
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

制約
	100 ≤ N ≤ 999
	N  は整数

入力
	入力は以下の形式で標準入力から与えられる．
	N

出力
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回かを出力せよ．

入力例 1 
	111
出力例 1 
	111
	次に行われる ABC は第 111 回です． これは黒橋君が初めて参加する ABC としてふさわしいです．

入力例 2 
	112
出力例 2 
	222
	次に行われる ABC は第 112 回です．そのため，第 111 回の ABC にはもう参加することはできません． 
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第 222 回です．

入力例 3 
	750
出力例 3 
	777

'''

def main():
	'''
	メイン関数
	'''
	
	
	next = input()
	h = next[0] 
	d = next[1] 
	o = next[2] 
	
	
	zoro = int(h)*100 + int(h)*10 + int(h)

	
	if (h==d) and (d==o) :
		print(next)
	
	elif int(next) < zoro :
		print(zoro)
	else :
	
		print(zoro+111)


if __name__ == '__main__':
	main()

Solution (Python):
x=input()


if x[0]==x[1]==x[2]:
	print(int(x))
elif x[1]<=x[0] and x[2]<=x[0]:
	print(int(x[0]+x[0]+x[0]))
else:
	print(int(str(int(x[0])+1)+str(int(x[0])+1)+str(int(x[0])+1)))

Solution (Python):
N=int(input())
kurai=N//100
zorome=kurai*111
if(N-zorome>0):
    print(zorome+111)
else:
    print(zorome)

Solution (Python):
n=int(input())
for i in range(n,n+111):
    x=str(i)
    m=i
    if x[0]==x[1]==x[2]:
        break
print(m)