#include <bits/stdc++.h>   using namespace std;   char ss[8][5] = { 1869 ,  6198 ,  1896 ,  1689 ,  1986 ,  1968 ,  1698 };   string s;   int x, cnt, vis[1000010];   int main() {     cin >> s;     int len = s.length();     for (register int i = 0; i < len; i++) {       if (s[i] ==  0 )         cnt++;       else if (!vis[s[i]] and                (s[i] ==  1  or s[i] ==  6  or s[i] ==  8  or s[i] ==  9 ))         vis[s[i]] = 1;       else {         x = (x << 3) + (x << 1) + (s[i] ^ 48);         x %= 7;         cout << s[i];       }     }     if (x == 0)       cout << 1869;     else if (x == 1)       cout << 6198;     else if (x == 2)       cout << 1896;     else if (x == 3)       cout << 1689;     else if (x == 4)       cout << 1986;     else if (x == 5)       cout << 1968;     else if (x == 6)       cout << 1698;     for (int i = 1; i <= cnt; i++) cout << 0;     cout << endl;   }   