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

n = input()
new_n = ""
one = -1
six = -1
eight = -1
nine = -1

nulls = 0

for el in n:
    if el == '0':
        nulls += 1
    elif el == '1':
        one += 1
    elif el == '6':
        six += 1
    elif el == '8':
        eight += 1
    elif el == '9':
        nine += 1
    else:
        new_n += el

if new_n == '':
    if one > 0:
        print(six * '6', eight * '8', nine * '9', one * '1', mod[1], nulls * '0', sep='')
    elif six > 0:
        print(eight * '8', nine * '9', one * '1', six * '6', mod[6], nulls * '0', sep='')
    elif eight > 0:
        print(six * '6', nine * '9', one * '1', eight * '8', mod[1], nulls * '0', sep='')
    elif nine > 0:
        print(six * '6', eight * '8', one * '1', nine * '9', mod[2], nulls * '0', sep='')
    else:
        print(9681, nulls * '0', sep='')

else:
    print(six * '6', eight * '8', nine * '9', one * '1', new_n, mod[int(new_n[-1]) % 7], nulls * '0', sep='')