# -*- coding: utf-8 -*-





def main():

    n = int(eval(input()))



    for i in range(100, 1000):

        if i % 111 == 0 and i >= n:

            print(i)

            exit()





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-





def main():

    n = int(eval(input()))



    # See:

    # https://www.youtube.com/watch?v=fYS-rAUSD5o

    for i in range(111, 1000, 111):

        if i >= n:

            print(i)

            exit()





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
def main():
    n = int(eval(input()))
    for i in range(100, 1000):
        if i % 111 == 0 and i >= n:
            print(i)
            exit()


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
def main():
    n = int(eval(input()))
    # See:
    # https://www.youtube.com/watch?v=fYS-rAUSD5o
    for i in range(111, 1000, 111):
        if i >= n:
            print(i)
            exit()


if __name__ == "__main__":
    main()

-    for i in range(100, 1000): -        if i % 111 == 0 and i >= n: +    # See: +    # https://www.youtube.com/watch?v=fYS-rAUSD5o +    for i in range(111, 1000, 111): +        if i >= n: