N = int(eval(input()))

print((min([111*i-N for i in range(1,10) if 111*i>=N])+N))

N = int(eval(input()))

for i in range(N,1000):

    if len(set(str(i))) == 1:

        print(i)

        exit()
N = int(eval(input()))
print((min([111 * i - N for i in range(1, 10) if 111 * i >= N]) + N))

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

-print((min([111 * i - N for i in range(1, 10) if 111 * i >= N]) + N)) +for i in range(N, 1000): +    if len(set(str(i))) == 1: +        print(i) +        exit()