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.
a = input();
d = [0] * 10;
for c in a :
    d[int(c)] += 1;
s = "";
ost = 0;
step = int(str(1) + str("0" * d[0]));
for i in [2,3,4,5,7] :
    s += str(i) * d[i];
for i in [1,6,8,9] :
    s += str(i) * (d[i] - 1);

print(s);

if s == "" :
    number = 0;
else :
    number = int(s);

ost = (number * step * 10000) % 7;
if ost == 0 :
    s += "1869";
if ost == 1 :
    s += "1968";
if ost == 2 :
    s += "1689";
if ost == 3 :
    s += "6891";
if ost == 4 :
    s += "1689";
if ost == 5 :
    s += "1986";
if ost == 6 :
    s += "1896";

s += "0" * d[0];

print(s);