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;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  os << '[';
  for (int i = 0; i < (int)(a.size()); i++) os << (i ? " " : "") << a[i];
  return os << ']';
}
template <typename T1>
inline void deb(const T1 &);
template <typename T1, typename T2>
inline void deb(const T1 &, const T2 &);
template <typename T1, typename T2, typename T3>
inline void deb(const T1 &, const T2 &, const T3 &);
template <typename T1, typename T2, typename T3, typename T4>
inline void deb(const T1 &, const T2 &, const T3 &, const T4 &);
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline void deb(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &);
template <typename T1>
inline void deb(const T1 &V1) {}
template <typename T1, typename T2>
inline void deb(const T1 &V1, const T2 &V2) {}
template <typename T1, typename T2, typename T3>
inline void deb(const T1 &V1, const T2 &V2, const T3 &V3) {}
template <typename T1, typename T2, typename T3, typename T4>
inline void deb(const T1 &V1, const T2 &V2, const T3 &V3, const T4 &V4) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline void deb(const T1 &V1, const T2 &V2, const T3 &V3, const T4 &V4,
                const T5 &V5) {}
class Solver {
 public:
  const int INF = 1 << 29;
  const double EPS = 1e-10;
  double zero(double d) { return d < EPS ? 0.0 : d; }
  const int M = 1000000007;
  Solver() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);
  }
  long long make_pair(int t) {
    long long a = 1ll;
    for (int i = 0; i < (int)(t); i++) a *= 10;
    return (long long)a;
  }
  string mods[7] = {"1869", "8961", "1689", "6198", "1698", "8916", "8196"};
  void solve() {
    string str;
    cin >> str;
    stringstream res;
    int zero = 0;
    bool one = false, six = false, eight = false, nine = false;
    int mod = 0;
    for (int i = 0; i < (int)(str.size()); i++) {
      char s = str[i];
      if (s == '0')
        zero++;
      else if (s == '1' && !one)
        one = true;
      else if (s == '6' && !six)
        six = true;
      else if (s == '8' && !eight)
        eight = true;
      else if (s == '9' && !nine)
        nine = true;
      else {
        res << s;
        mod = ((mod * 10) + (s - '0')) % 7;
      }
    }
    res << mods[(mod * 10) % 7];
    for (int i = 0; i < (int)(zero); i++) res << '0';
    cout << res.str() << endl;
  }
};
int main() {
  Solver sb;
  sb.solve();
  return 0;
}
