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

Solution (Python):

N = list(input())
n = int("".join(N))
ck = int(N[0] * 3)
if n - ck <= 0:
    print(int(N[0] * 3))
else:
    print(int(str(int(N[0])+1)*3))
pass

Solution (Python):
def answer(n: int) -> int:
    q = n // 111
    if n % 111 != 0:
        q += 1

    return 111 * q


def main():
    n = int(input())
    print(answer(n))


if __name__ == '__main__':
    main()

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

for i in range(110):
    if n % 111 == 0:
        break
    else:
        n += 1
        
print(n)

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

Solution (Python):
def isSame(n):
    if n[0] == n[1] and n[1] == n[2]:
        return True
    else:
        return False

n_s = input()
n_i = int(n_s)

while True:
    if isSame(n_s):
        print(n_s)
        break
    else:
        n_i += 1
        n_s = str(n_i)

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

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

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

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

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

ans = 0
flag = 0
for i in range(n,1000): 
    s = str(i)
    n_list = list(s)
    if n_list[0] == n_list[1] and n_list[1] == n_list[2] and flag == 0:
        flag = 1
        ans = i
        
print(ans)

Solution (Python):
n=int(input())
hyaku=(n-n%100)/100
if n%100>hyaku*10+hyaku:
    hyaku+=1
    print(int(hyaku*100+hyaku*10+hyaku))
else:
    print(int(hyaku*100+hyaku*10+hyaku))

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

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

n=[int(i) for i in n_list]

ans=str(n[0]+1)*3

if n[0]>n[1]:
    ans=str(n[0])*3

elif n[0]==n[1]:
    if n[1]>=n[2]:
        ans=str(n[0])*3
        
print(ans)

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

for i in range(9):
    if n <= ans:
        print(ans)
        exit()
    else:
        ans += 111

Solution (Python):

url = "https://atcoder.jp//contests/abc111/tasks/abc111_b"

def main():
    s = input()
    for n in range(int(s), 1000):
        str_n = str(n)
        if len(str_n) == str_n.count(str_n[0]):
            print(n)
            exit()



if __name__ == '__main__':
    main()

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

Solution (Python):
N = input()
max_digit = N[0]

min_tmp = ''
max_tmp = ''
for i in range(len(N)):
    min_tmp += max_digit
    max_tmp += str(int(max_digit) + 1)
    
if  int(min_tmp) >= int(N):
    print(min_tmp)
else:
    print(max_tmp)

Solution (Python):
import sys

N = int(input())

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

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

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

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

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

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

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

Solution (Python):

i = int(input())

for i in range(i, 1000):
    a = int((i/10)%10)
    b = int(i % 10)
    c = int(i /100)
    if a == b and b == c and c == a:
        print(i)
        exit(0)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

oklist = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = ir()
ind = bisect.bisect_left(oklist, n)
print(oklist[ind])

Solution (Python):
N=input()
L=len(N)
if int(N[0]*L)>=int(N):
    print(int(N[0]*L))
else:
    print(int((N[0])*L)+111)

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

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

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

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

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

Solution (Python):
from math import ceil

n = int(input())
if n%111 == 0:
    print(n)
else:
    print(111*ceil(n/111))

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


main()

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

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

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

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


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import sys
n=input()
n=list(n)

if n[0]>n[1]:
  print(n[0]*3)
  sys.exit()

if n[0]<n[1]:
  print(str((int(n[0])+1))*3)
  sys.exit()
  
if n[0]==n[1]>=n[2]:
  print(n[0]*3)
  sys.exit()

if n[0]==n[1]<n[2]:
  print(str((int(n[0])+1))*3)
  sys.exit()

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

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

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

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

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

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

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

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

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

Solution (Python):


a=input()








zyun= len(a)*9+int(a[0])
zoro=0
z = zyun//9
af= zyun%9
if af==0:
    if int(a)<=int(str(9)*(z-1)):
        print(int(str(9)*(z-1)))
    else:
            print(str(1)*(z))
else :
    if int(a)<=int(str(af)*(z)):
        print(int(str(af)*(z)))
    else:
        print(int(str(af+1)*(z)))

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

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

h = n // 100
x = h * 100 + h * 10 + h
print(x) if n <= x else print(x + 111)

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

Solution (Python):
n = int(input())
for i in range(1, 10):
    l = [i, i, i]
    num = int(''.join(map(str, l)))
    if n <= num:
        print(num)
        break

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

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

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

Solution (Python):
def main():
    n = input()
    if n[0] == '0':
        print('111')
    elif n[0] < n[1] or n[0] < n[2]:
        print((int(n[0]) + 1) * 111)
    else:
        print(int(n[0]) * 111)


if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())

zorome_contest = [111*i for i in range(1, 10)]
diff_min = 10**10
ans = 0

for contest in zorome_contest:
    if contest - N >= 0 and contest - N < diff_min:
        diff_min = contest - N
        ans = contest
print(ans)

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

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

Solution (Python):
n=input()
k = int(n) % 111
if k==0:
    print(n)
else:
    if n[0]>n[1] or (n[0]==n[1] and n[1]>n[2]):
        print(n[0]*3)
    else:
        print((str(int(n[0])+1))*3)

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

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

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


if __name__ == "__main__":
    main()

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
a = 111
for _ in range(9):
    if n <= a:
        print(a)
        exit()
    a += 111

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

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

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

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

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

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

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

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):
a=int(input())
b=a%100
c=a//100
if b<=c*11:
  print(c*111)
else:
  print((c+1)*111)

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

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

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

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

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

else:
    print(111*int((N/111)))

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

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

Solution (Python):
import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
    n = int(input())
    for i in range(n, 1000):
        flag = True
        for j, c in enumerate(str(i)):
            if j == 0:
                continue
            else:
                if c != str(i)[0]:
                    flag = False
                    break
        if flag:
            return i

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

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

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

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

f = N
while True:
  x = str(f)
  if all(x[i] == x[0] for i in range(len(x))):
    print(x)
    exit()
  else:
    f += 1

Solution (Python):
n = list(input())
x = int(n[0]*3)
y = int(n[0]+n[1]+n[2])
if x >= y:
  print(x)
else:
  print(x+111)

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

Solution (Python):
N=int(input())
if N<=111:
    print(111)
elif 112<=N and N<=222:
    print(222)
elif 223<=N and N<=333:
    print(333)
elif 334<=N and N<=444:
    print(444)
elif 445<=N and N<=555:
    print(555)
elif 556<=N and N<=666:
    print(666)
elif 667<=N and N<=777:
    print(777)
elif 778<=N and N<=888:
    print(888)
elif 889<=N and N<=999:
    print(999)

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

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

i = n
while True:
    if str(i)[0] != str(i)[1] or str(i)[1] != str(i)[2]:
        i += 1
    else:
        break
print(i)

Solution (Python):
contests = [i for i in range(100,1000) if i % 111 == 0]
N = int(input())
for contest in contests:
  if contest >= N:
    print(contest)
    break
  else:
    continue

Solution (Python):
n = int(input())
str_n = str(n)
keta = len(str_n)
suji = [str(i) for i in range(10)]

ans = 0
for i in range(int(str_n[0]),10):
    tmp = ''
    for j in range(keta):
        tmp += suji[i]
    
    if int(tmp)>=n:
        ans = int(tmp)
        break
print(ans)

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

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

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

Solution (Python):
N = int(input())
count=0
for i in range(1,10):
    if (N-1)//int(str(i)*3)>=1:
        count=i
print(str(count+1)*3)

Solution (Python):
import sys
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)
        sys.exit()

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

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

while n % 111 != 0:
    n += 1
    if n % 111 == 0:
        print(n)
        exit()

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

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

Solution (Python):
n = int(input())
a = -(-n//111)
if a == 10:
    print(1111)
else:
    print(a*111)

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

Solution (Python):
n = int(input())
li = [int(str(i)*3) for i in range(10)]
import bisect
x = bisect.bisect_left(li,n)
print(li[x])

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    return


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
N = input()

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

else:
    if int(N[0]) < int(N[1]):
        x = (int(N[0])+1) * 100 + (int(N[0])+1) * 10 + int(N[0])+1
        print(x)

    elif N[0] == N[1] and int(N[1]) > int(N[2]):
        x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
        print(x)

    elif N[0] == N[1] and int(N[1]) < int(N[2]):
        x = (int(N[0])+1) * 100 + (int(N[0])+1) * 10 + int(N[0])+1
        print(x)

    elif int(N[0]) > int(N[1]):
        x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
        print(x)

Solution (Python):









n = int(input())

q, mod = divmod(n,111)

if mod == 0:
    print(q*111)
else:
    print((q+1)*111)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
for i in range(n,1000):
    s = str(i)
    if s[0] == s[1] == s[2]:
        print(i)
        exit()

Solution (Python):
N = int(input())
S = str(N)
x = int(S[0])
y = int(S[1])
z = int(S[2])
if x > y:
    ans = x*100+x*10+x
elif x < y:
    x += 1
    ans = x*100+x*10+x
else:
    if x > z:
        ans = x*100+x*10+x
    elif x < z:
        x += 1
        ans = x*100+x*10+x
    else:
        ans = N
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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

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

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    while True:
        if len(set(str(n))) == 1:
            print(n)
            break
        n += 1
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
print(-(-N//111)*111)

Solution (Python):
val = [111*i for i in range(1, 10)]
N = int(input())
while not N in val:
  N += 1
print(N)

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

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

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

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

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

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

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    dif = 999
    ans = ''
    for i in range(1, 10):
        tmp = str(i) * 3
        if dif > int(tmp) - n >= 0:
            dif = abs(n - int(tmp))
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

Solution (Python):

N = int(input())
for i in range(10):
    num = 100*i+10*i+i
    if num>=N:
        print(num)
        break

Solution (Python):
x = [i * 111 for i in range(1, 10)]
N = int(input())
for j in range(len(x)):
  if 0 <= x[j] - N <= 110:
    print(x[j])
    break

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

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

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

m = []

y = n
while y > 0:
    z = y % 10
    m.append(z)
    y = int(y / 10)
    
p = m[len(m) - 1]


max_num = 0
for i in range(len(m)):
    max_num = max(max_num, m[i])

if p < max_num:
    p += 1


for i in range(len(m)):
    m[i] = p
    print(m[i], end='')

print('')

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

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

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

Solution (Python):
if __name__ == '__main__':
	
	n = int(input())


	for i in range(n,1000):
		tmp = set(str(i))

		if len(tmp) == 1:
			print(i)
			break

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

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

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

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

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

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

n=int(input())

for i in a:
  if n>i:
    continue
    
  else:
    print(i)
    exit()

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

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

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

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

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

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

if x < int(r):
  print( ((int(n[0])+1)*100 + (int(n[0])+1)*10 + int(n[0])+1))
else:
  print(x)

Solution (Python):
N = int(input())
a = 0
for i in range(N,1000):
  if i == 111 or i == 222 or i == 333 or i ==444 or i ==555 or i == 666 or i ==777 or i ==888 or i == 999:
    a = i
    break
print(a)

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

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

Solution (Python):
















































def calculation(lines):
    N = int(lines[0])
    
    

    if N % 111 == 0:
        result = N
    else:
        result = -(-N//111) * 111 

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['111']
        lines_export = [111]
    if pattern == 2:
        lines_input = ['112']
        lines_export = [222]
    if pattern == 3:
        lines_input = ['750']
        lines_export = [777]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

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

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

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

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


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

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

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

for i in num:
    if i >= n:
        print(i)
        exit()

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

def checkDigit(n):
  a = n % 10
  n = (n-a)//10
  b = n % 10
  c = (n-b)//10
  if a == b and b == c:
    return True
  else:
    return False

for i in range(1000):
  if checkDigit(N):
    print(N)
    break
  N += 1

Solution (Python):

import sys

N = int(input())
num =[111,222,333,444,555,666,777,888,999]
for i in range(8):
    if N <= num[0]:
        ans =111
        break
    elif  num[i] < N <= num[i+1]:
        ans =num[i+1] 

print(ans)

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

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

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

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

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
import math
def main():
  n=int(input())
  a=int(n/100)
  if a*100+a*10+a>=n:
    print(a*100+a*10+a)
  else:
    print((a+1)*100+(a+1)*10+a+1)
main()

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(9):
  if n<=i*111:
    print((i)*111)
    break
else:
  print(999)