You have number *a*, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.

Number *a* doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.
The first line contains positive integer *a* in the decimal record. It is guaranteed that the record of number *a* contains digits: 1, 6, 8, 9. Number *a* doesn't contain any leading zeroes. The decimal representation of number *a* contains at least 4 and at most 10<sup class="upper-index">6</sup> characters.
n=int(input())
t=0
a=0
b=0
c=0
d=0
z=0
while n:
    x=n%10
    if x==1 and a==0:
        a=1
    elif x==6 and b==0:
        b=1
    elif x==8 and c==0:
        c=1
    elif x==9 and d==0:
        d=1
    else:
        t*=10
        t+=x
    if x==0:
        z+=1
    n//=10
if t%7==0:
    t*=10000
    t+=1869
elif t%7==1:
    t*=10000
    t+=1968
elif t%7==2:
    t*=10000
    t+=1689
elif t%7==3:
    t*=10000
    t+=6198
elif t%7==4:
    t*=10000
    t+=1698
elif t%7==5:
    t*=10000
    t+=1986
else:
    t*=10000
    t+=8196
while z:
    z-=1
    t*=10
print(t)
