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.
a=input()
cnt=[0,0,0,0,0,0,0,0,0,0]
for i in a:
    cnt[int(i)]=cnt[int(i)]+1
cnt[1]=cnt[1]-1
cnt[6]=cnt[6]-1
cnt[8]=cnt[8]-1
cnt[9]=cnt[9]-1
u=""
for i in range(0,10):
    for j in range(0,cnt[10-i-1]):
        u=u+str(10-i-1)
print(u,end="")
if int(u)%7==1:
    print(1896)
if int(u)%7==0:
    print(1869)
if int(u)%7==2:
    print(1986)
if int(u)%7==6:
    print(1968)
if int(u)%7==3:
    print(1698)
if int(u)%7==5:
    print(1689)
if int(u)%7==4:
    print(6891)