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.
m=[9681, 8961, 9816, 6891, 8691, 9861, 8196]

s=input("")

a=b=c=d=0;
ss=''
z=''
for i in range(len(s)):
    if s[i]=='1' and a==0:
        a+=1

    elif s[i]=='6' and b==0:
        b+=1

    elif s[i]=='8' and c==0:
        c+=1

    elif s[i]=='9' and d==0:
        d+=1
    elif s[i]=='0':
        z+=s[i]
    else:
        ss+=s[i]

for i in m:
    k=ss+str(i)+z
    h=int(k)
    if h%7==0:
        print(h)
        break