import sys

s=input()
for i in range(10):
    s1=s+str(i)
    if int(s1)%7==0:
        print(s1)
        break