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())
a = N//100

if N%111 == 0:
    print(N)
elif 111*a > N:
    print(111*a)
else:
    print(111*(a+1))

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

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

if (s % 111 != 0):
  i = i + 1
  
print(i * 111)

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

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

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

Solution (Python):

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

Solution (Python):
n=list(map(int,input()))
i=n[0]
  
if n[0]>=n[1]:
  if n[0]==n[1]<n[2]:
    n[0],n[1],n[2]=i+1,i+1,i+1
  elif n[0]==n[1]==n[2]:
    n[0]=i
  else:
    n[1],n[2]=i,i
else:
  n[0],n[1],n[2]=i+1,i+1,i+1

for i in n:
  print(i,end='')

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

n_min=list(n[0]*3)
n_min=int("".join(n_min))

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

n_max=list(a*3)
n_max=int("".join(n_max))




if n_min>=ans:
    print(n_min)
else:
    print(n_max)

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


if N in ans:
    print(N)
else:
    for i in range(9):
        if N > ans[i]:
            continue
        else:
            print(ans[i])
            break

Solution (Python):
n = input()
nlower = int(''.join(list(n[0] * len(n))))
nupper = int(''.join(list(str(int(n[0]) + 1) * len(n))))
if nlower > int(n) or nlower == int(n):
    print(nlower)
else:
    print(nupper)

Solution (Python):

n = input()

temp = n[0]*len(n)

if int(n) <= int(temp):
    print(int(temp))
elif n[0] == "9":
    print("1" * (len(n) + 1))
else:
    print(str(int(n[0])+1)*len(n))

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

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

Solution (Python):
n=int(input())
a,b=divmod(n,111)
if b==0:
    print(str(a)*3)
else:
    print(str(a+1)*3)

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

a = n // 100
b = (n%100) // 10
c = n % 10


if a < b:
    ans = (a+1)*100 + (a+1)*10 + a+1
elif a == b:
    if c <= b:
        ans = a*100 + a*10 + a
    else:
        ans = (a+1)*100 + (a+1)*10 + a+1
else:
    ans = a*100 + a*10 + a

print(ans)

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

Solution (Python):



N = int(input())
N_len = len(list(str(N)))

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

Solution (Python):
N = int(input())
ans = ["111", "222", "333", "444", "555", "666", "777", "888", "999"]
if not(N % 111):
    print(ans[int(N/111) - 1])
else:
    print(ans[int(N/111)])

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(N, 1112):
    matched = True
    for j in range(1, len(str(i))):
        if str(i)[j - 1] != str(i)[j]:
            matched = False
            break
    if matched:
        print(i)
        exit(0)

Solution (Python):
N = int(input())
digit = N//100

boundary_num = digit * 111
if N <= boundary_num:
    print(boundary_num)
else:
    print(boundary_num+111)

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

ans = 0

N_len = len(N)
judge = True
if(N_len==1):
    print(int(N[0]))
else:
    for i in range(1,N_len):
        if int(N[0]) < int(N[i]):
            judge = False
            break
    
    if judge :
        for i in range(N_len):
            ans = ans + int(N[0])*10**i
    else :            
        for i in range(N_len):
            ans = ans + (int(N[0])+1)*10**i

    print(ans)

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

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

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

print(i * 111)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


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


def B():
    n = II()
    for i in range(111, 1000, 111):
        if n <= i:
            print(i)
            return
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

Solution (Python):
x=input()
xv=int(x)
n=len(x)

y=''
x1=str(int(x[0])+1)
z=''

for i in range(n):
	y=y+x[0]
	z=z+x1

yv=int(y)
zv=int(z)

if xv<=yv:
	res=yv
else:
	res=zv

print(res)

Solution (Python):
N = int(input())
ans = 0
for i in range(1, 10):
    if N == int(str(i) + str(i) + str(i)):
        ans = int(str(i) + str(i) + str(i))
        break
    elif N < int(str(i) + str(i) + str(i)):
        ans = int(str(i) + str(i) + str(i))
        break

print(ans)

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

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

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

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

res = int(n[0])*111
if res - num < 0:
    res = (int(n[0])+1)*111
print(res)

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

Solution (Python):
inp = input()
n = list(inp)
x = int(n[0]+n[0]+n[0])
print(x) if int(inp)<=x else print(x+111)

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

a = n // 100
if n <= int(str(a) * 3):
    print(str(a) * 3)
else:
    print(str(a + 1) * 3)

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


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

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

Solution (Python):
N=int(input())
if N%111==0:
    print(N)
else:
    for i in range(9):
        if (i+1)*111-N>0:
            print((i+1)*111)
            break
        else:
            continue

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

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

Solution (Python):
N = input()

top = N[0]
little = True
for n in N:
    if int(n) > int(top):
        little = False
        break

if little:
    print(top*len(N))
else:
    print(str(int(top)+1)*len(N))

Solution (Python):
import sys
N = int(input())
for i in range(N, N*10):
    cur = 0
    for x, y in zip(str(i), str(i)[1:]):
        if x != y:
            break
        else:
            cur += 1
    if cur == 2:
        print(i)
        sys.exit()

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

Solution (Python):
N=input()

ans=int(N)//100

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

elif N[0:2]<N[1:3]:
    print((ans+1)*100+(ans+1)*10+ans+1)
else:
    print(ans*100+ans*10+ans)

Solution (Python):
N = int(input())
for x in range(999):
  if str(N).count(list(str(N))[0]) == 3:
    print(N)
    break
  else:
    N += 1

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

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

Solution (Python):
def is_good(m):
    for i in range(2):
        a = m % 10
        m //= 10
        b = m % 10
        if a != b:
            return False
    return True

n = int(input())
while True:
    if is_good(n):
        print(n)
        break
    n += 1

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

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

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

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

i = 0
while N <= KAI[i]:
     i += 1

print(KAI[i-1])

Solution (Python):
n = input()

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

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

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

print(n)

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

x = N
while(1):
    s = str(x)
    if(s[0] == s[1] == s[2]):
        print(x)
        break
    else:
        x += 1

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(n,1000):
    i = list(str(i))
    if len(list(set(i))) == 1:
        print(''.join(i))
        quit()

Solution (Python):
n = input()

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

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

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

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

Solution (Python):
a = input()
b = 0
b = int(a[0] + a[0] + a[0])
if b < int(a):
    b += 111
print(b)

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

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





if n% 111 == 0:
  print(n)
  quit()
print(n + 111 - n % 111 )

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




c =  int(n[0] * 3)

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

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

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

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

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

if n in n_list:
  print(n)

for i in range(len(n_list)):
  if i == 0 and n < n_list[0]:
    print(n_list[0])
  if n_list[i-1] < n < n_list[i]:
    print(n_list[i])

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

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

Solution (Python):
S = input()
N = list(S)
ans = N[0]+N[0]+N[0]
if int(ans) < int(S):
  print(str(int(N[0])+1)+str(int(N[0])+1)+str(int(N[0])+1))
else:
  print(ans)

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

Solution (Python):
def all_digits_same(N, d):
    if N == d:
        return True
    elif N % 10 != d:
        return False
    return all_digits_same(N // 10, d)

N = int(input())

while True:
    if all_digits_same(N, N % 10):
        print(N)
        break
    N += 1

Solution (Python):
N = input()

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

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

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

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

a = s//100
if s%(a*100) <= a*10+a:
    print(a*100+a*10+a)
else:
    print(((a+1)*100+(a+1)*10+(a+1)))

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

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

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

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

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

i=0
while lst[i]<N:
    i+=1
    
print(lst[i])

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

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

Solution (Python):
nx = input()
n=int(nx)
x=111
for i in range (111,n,111):
    x+=111
print(x)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

for i in range(1000):
    st = set()
    for k in str(i+N):
        st.add(k)
    if len(st) == 1:
        print(i+N)
        exit()

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

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

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

print(x)

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

top = n // 100
if n <= top * 111:
    print(top * 111)
else:
    print((top+1)*111)

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

answer = []
for i in range(1,10) :
    num = int(str(i)+str(i)+str(i))
    calc = num-n
    if calc >=  0 :
        answer.append((num,calc))

print(answer[0][0])

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

Solution (Python):

N = int(input())


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

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

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

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

Solution (Python):



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

Solution (Python):



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

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

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

Solution (Python):
def abc():
    s = input().rstrip()
    if len(set(s)) == 1:
        print(s)
        return
    for i in range(int(s), 1000):
        if len(set(str(i))) == 1:
            print(i)
            return


abc()

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


if n in lst:
    print(n)
    exit()

for i in range(1, 10):
    if n >= lst[i-1] and n <= lst[i]:
        print(lst[i])
        exit()
    elif n >= 100 and n <= 110:
        print(lst[0])
        exit()

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
N=int(input())
L = [111, 222, 333, 444, 555,
     666, 777, 888, 999]
diff = [l-N if l >= N else 1000 for l in L]
print(L[diff.index(min(diff))])

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

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

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

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

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

for i in range(10):

    if (i != 0 and N <= i * 111):
        print( i*111 )
        break

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = input()

while 1:

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

    n = str(int(n)+1)

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

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

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

if(N > 111 and N <= 222):
    print('222')
if(N > 222 and N <= 333):
    print('333')
if(N > 333 and N <= 444):
    print('444')
if(N > 444 and N <= 555):
    print('555')
if(N > 555 and N <= 666):
    print('666')
if(N > 666 and N <= 777):
    print('777')
if(N > 777 and N <= 888):
    print('888')
if(N > 888 and N <= 999):
    print('999')
if N <= 111:
    print('111')

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

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
while len(Counter(str(N)).keys()) != 1:
    N += 1
print(N)

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

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

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

Solution (Python):
N = int(input())
for i in range(N, N+120):
    if len(set(list(str(i)))) == 1:
        res = i
        break
print(res)

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

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

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

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

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

i=0
while True:
    if n>list[i]:
        i+=1
    else:
        print(list[i])
        break

Solution (Python):
N = int(input())
kouho = [111, 222, 333, 444, 555, 666, 777, 888, 999]
result = 999
for k in kouho:
    if k < N:
        continue
    else:
        result = k
        break
print(result)

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

a=(n-n%100)//100
b=(n-a*100-n%10)//10
c=n%10

if  a>b or a==b and b>=c:
    print(a*100+a*10+a)

else:
    print((a+1)*100+(a+1)*10+a+1)

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

a=(n-n%100)//100
b=(n-a*100-n%10)//10
c=n%10

if  a>b:
    print(a*100+a*10+a)
elif a<b:
    print((a+1)*100+(a+1)*10+a+1)
else:
    if b>=c:
        print(a*100+a*10+a)
    else:
        print((a+1)*100+(a+1)*10+a+1)

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

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

for i in range(len(goodABC)):
  if N <= goodABC[i]:
    print(goodABC[i])
    exit()

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

Solution (Python):
from collections import Counter

N = int(input())

for cnt in range(N,1000):
    if len(Counter(list(str(cnt))).most_common()) == 1:
        print(cnt)
        break

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

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

Solution (Python):
n = input()
candidates = [3*str(i) for i in range(1,10)]
for i, j in enumerate(candidates):
    if n <= j:
        print(j)
        break

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

def solve(n):
    if str(n)[0] == str(n)[1] == str(n)[2]:
        print(n)
    else:
        solve(n+1)

solve(n)

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


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

else:
    a = 111 - (n % 111)
    print(n+a)

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

can = True
while can:
    if len(set(list(str(n)))) == 1:
        print(n)
        can = False
    n += 1

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

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

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(1,10):
    if i*100+i*10+i>=n:
        print(i*100+i*10+i)
        break

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

if N % 111 == 0:
    print(N)
else:
    print(N//111 * 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())
contest_date = [111,222,333,444,555,666,777,888,999]
print(contest_date[(N-1)//111])

Solution (Python):
n=int(input())
a=(n-n%100)//100
if a==9:
    print(999)
else:
    ans=100*a+10*a+a
    if ans>=n:
        print(ans)
    else:
        print(ans+111)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N = input()
n = []
for v in N:
    n.append(v)
if (n[0]>=n[1]) and (n[0]>=n[2]):
    print(int(n[0]+n[0]+n[0]))
else:
    n[0] = str(int(n[0]) + 1)
    print(int(n[0]+n[0]+n[0]))

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

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

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

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

cnt = 0

while True:
    x = str(N + cnt)
    if len(x) >= 4:
        if x[0] == x[1] and x[0] == x[2] and x[0] == x[3]:
            break
    else:
        if x[0] == x[1] and x[0] == x[2]:
            break
    cnt += 1
    
print(x)

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

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

Solution (Python):

N = input()
lst_N = list(N)

while 1:

    if lst_N[0] == lst_N[1] == lst_N[2]:
        break

    N = ''.join(lst_N)
    N = int(N)
    N += 1
    N = str(N)
    lst_N = list(N)

print(int(N))

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def ok(n):
    s = str(n)
    if len(set(s)) == 1:
        return True
    return False

def solve():
    n = f()[0]
    for i in range(n, 1000):
        if ok(i):
            print(i)
            return

solve()

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

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

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

Solution (Python):
n = input()

if n[0] < n[1]:
    x = int(n[0]) + 1
    temp_100 = x*100 + x*10 + x
    print(temp_100)
elif n[0] > n[1]:
    x = int(n[0]) 
    temp_100 = x*100 + x*10 + x
    print(temp_100)
else :
    if n[1] < n[2]:
        x = int(n[0]) + 1
        temp_100 = x*100 + x*10 + x
        print(temp_100)
    elif n[1] >= n[2]:
        x = int(n[0]) 
        temp_100 = x*100 + x*10 + x
        print(temp_100)

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

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

Solution (Python):
from sys import stdin
N = stdin.readline().rstrip()
if int(N) > int(N[0] * 3):
    print(str(int(N[0]) + 1) * 3)
else:
    print(N[0] * 3)

Solution (Python):
N = input()
c = int(N[0] + N[0] + N[0])

if int(N) - c <= 0:
    print(c)
else:
    print(c + 111)

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

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

for n in range(N,1000):
  if n%111 == 0:
    print(n)
    exit()

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

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

Solution (Python):
s = input()
s0 = int(s[0])
s1 = int(s[1])
s2 = int(s[2])

if s0 == s1 and s1 == s2:
    print(int(s))
elif s1 == s0:
    if s0 > s2:
        print("".join([str(s0)] * 3))
    else:
        print("".join([str(s0+1)] * 3))
elif s1 > s0:
    print("".join([str(s0+1)] * 3))
elif s1 < s0:
    print("".join([str(s0)] * 3))

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

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

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

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

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

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

N = int(input())

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

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

Solution (Python):
print(min(range(999,int(input())-1,-111)))

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

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

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