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.

def binpow(b,e):
    if e == 0:
        return 1
    if b == 0:
        return 0
    inter = binpow(b,e//2)
    if e%2 == 1:
        return (inter*inter*b)%7
    else:
        return (inter*inter)%7


n = list(input())
L = list(map(int,n))
L.remove(1)
L.remove(6)
L.remove(8)
L.remove(9)
# print(L)

ans = 0
for i in L:
    ans = (10*ans + i)%7

# x*10^len(L) + ans = 0
# x = (-ans)*5^l

m = {1:1689, 2:1689, 3:6198, 4:1698, 5:1986, 6:1896, 0:1869}

wanted = ((-ans)*binpow(5,len(L)))%7

print(str(m[wanted]), end = "")
for i in L: print(i,end="")


