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
import java.io.*;
import java.util.*;

/**
 * 
 * @author Altynbek.Nurgaziyev
 */
public class R221_D2_C {

    char[] t;

    public boolean check(String s) {
        int k = 0;
        for (int i = 0; i < s.length(); i++) {
            k = k * 10 + (s.charAt(i) - '0');
            k = k % 7;
        }
        for (int i = 0; i < t.length; i++) {
            k = k * 10 + (t[i] - '0');
            k = k % 7;
        }
        if (k == 0) {
            out.print(s);
            for (int i = 0; i < t.length; i++) {
                out.print(t[i]);
            }
            out.println();
            return true;
        }
        return false;
    }

    public void solution() throws Exception {
        char[] s = in.next().toCharArray();
        boolean[] u = new boolean[10];
        char[] f = { '1', '6', '8', '9' };
        boolean[] used = new boolean[4];
        t = new char[s.length - 4];
        int k = 0;
        for (int i = 0; i < s.length; i++) {
            if ((s[i] == '1' || s[i] == '6' || s[i] == '8' || s[i] == '9')
                    && !u[s[i] - '0']) {
                u[s[i] - '0'] = true;
            } else {
                t[k++] = s[i];
            }
        }
        for (int a = 0; a < 4; a++) {
            used[a] = true;
            for (int b = 0; b < 4; b++) {
                if (!used[b]) {
                    used[b] = true;
                    for (int c = 0; c < 4; c++) {
                        if (!used[c]) {
                            used[c] = true;
                            for (int d = 0; d < 4; d++) {
                                if (!used[d]) {
                                    if (check(""
                                            + f[a]
                                            + f[b]
                                            + f[c]
                                            + f[d])) {
                                        return;
                                    }
                                }
                            }
                            used[c] = false;
                        }
                    }
                    used[b] = false;
                }
            }
            used[a] = false;
        }
    }

    Scanner in;
    PrintWriter out;
    String input, output;

    public void run() throws Exception {
        if (input != null) {
            in = new Scanner(new FileReader(input));
        } else {
            in = new Scanner(System.in);
        }

        if (output != null) {
            out = new PrintWriter(new File(output));
        } else {
            out = new PrintWriter(System.out);
        }

        solution();

        out.close();
    }

    public static void main(String[] args) throws Exception {
        new R221_D2_C().run();
    }

    public class Scanner {

        private BufferedReader br;
        private StringTokenizer st;

        public Scanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public Scanner(FileReader fr) {
            br = new BufferedReader(fr);
        }

        public String next() throws Exception {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public Integer nextInt() throws Exception {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws Exception {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws Exception {
            return Double.parseDouble(next());
        }
    }
}