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.
s=input()
cnt=[0]*10
for c in s:
    cnt[int(c)]+=1

if cnt[1]==1 and cnt[6]==1 and cnt[8]==1 and cnt[9]==1 and sum(cnt)==cnt[0]+4:
    print('9618'+'0'*cnt[0])
else:

    cnt[1]-=1
    cnt[6]-=1
    cnt[8]-=1
    cnt[9]-=1

    s=""
    mod=0
    for d in range(1,10):
        for i in range(cnt[d]):
            s+=str(d)
            mod*=10
            mod+=d
            mod%=7

    import itertools
    a=[1,6,8,9]
    for p in itertools.permutations(a):
        x=p[0]*1000+p[1]*100+p[2]*10+p[3]
        if (mod*10000+x)%7==0:
            s+=str(x)+'0'*cnt[0]
            print(s)
            break