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.

Input

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 106 characters.

Output

Print a number in the decimal notation without leading zeroes — the result of the permutation.

If it is impossible to rearrange the digits of the number a in the required manner, print 0.

Examples

Input

1689


Output

1869


Input

18906


Output

18690
#include <bits/stdc++.h>
using namespace std;
bool use[10];
char num[2000000];
int Nn, now, cnt;
char OAO[10][5] = {"1869", "6198", "1896", "1689", "1986",
                   "1968", "1698", "1869", "6198", "1896"};
int main() {
  scanf("%s", num);
  Nn = strlen(num);
  now = 0;
  for (int Ni = 0; Ni < Nn; Ni++) {
    if ((num[Ni] == '1' || num[Ni] == '6' || num[Ni] == '8' ||
         num[Ni] == '9') &&
        use[num[Ni] - '0'] == false) {
      use[num[Ni] - '0'] = true;
    } else if (num[Ni] - '0' == 0)
      cnt++;
    else {
      now *= 10;
      now += num[Ni] - '0';
      now %= 7;
      printf("%c", num[Ni]);
    }
  }
  printf("%s", OAO[now]);
  while (cnt--) {
    printf("0");
  }
  puts("");
}
