import re

import sys



n = int(eval(input()))



for i in range(n, 1000):

    if re.match('^([0-9])\\1+$', str(i)):

        print(i)

        sys.exit(0)
n = int(eval(input()))



for i in range(1, 10):

    if n <= i*111:

        print((i*111))

        exit()

import re
import sys

n = int(eval(input()))
for i in range(n, 1000):
    if re.match("^([0-9])\\1+$", str(i)):
        print(i)
        sys.exit(0)

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

-import re -import sys - -for i in range(n, 1000): -    if re.match("^([0-9])\\1+$", str(i)): -        print(i) -        sys.exit(0) +for i in range(1, 10): +    if n <= i * 111: +        print((i * 111)) +        exit()