n=int(eval(input()))

ans=999

for i in range(n,1000):

  if i%111==0:

    if i<=ans:

      ans=i

      

print(ans)



n=int(eval(input()))



if n%111==0:

  ans=n

else:

  while n%111>0:

    n+=1

    ans=n

    

print(ans)



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

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

-ans = 999 -for i in range(n, 1000): -    if i % 111 == 0: -        if i <= ans: -            ans = i +if n % 111 == 0: +    ans = n +else: +    while n % 111 > 0: +        n += 1 +        ans = n