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.
p, t = {}, input()
for i in '0123456789': p[i] = 0
for i in t: p[i] += 1
for i in '1689': p[i] -= 1

q = [0] * 7
r = pow(10, (len(t) - 4) % 6, 7)
for i, j in enumerate([9681, 6819, 6981, 6891, 8691, 9861, 1896]): q[(i * r) % 7] = j

s = [0] + [int('1' * i) % 7 for i in range(1, 6)]
a = b = d = 0
for i in '0123456789':
    b = (a + p[i]) % 6
    d -= ((s[b] - s[a]) * int(i)) % 7
    a = b

print(str(q[d % 7]) + ''.join(i * p[i] for i in '9876543210'))