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.StringTokenizer;

public class CodeForces {
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    void runCase(int caseNum) throws IOException {
        String[] perms = new String[] {"",
                "1968",
                "1689",
                "6198",
                "1698",
                "1986",
                "1896",
                "1869"};

        String str = next();
        boolean[] mark = new boolean[10];
        mark[1] = mark[6] = mark[8] = mark[9] = true;
        StringBuilder sb = new StringBuilder();
        int zeros = 0;

        long m = 0, d = 10000 % 7;
        for (char c : str.toCharArray()) {
            int a = c - '0';
            if (a == 0)
                ++zeros;
            else if (mark[a])
                mark[a] = false;
            else {
                sb.append(c);
                m += a * d;
                d = (d * 10) % 7;
            }
        }
        sb.reverse();
        m %= 7;

        System.out.print(sb);
        System.out.print(perms[7 - (int) m]);
        if (zeros > 0) {
            StringBuilder zstr = new StringBuilder();
            for (int i = 0; i < zeros; ++i)
                zstr.append("0");
            System.out.print(zstr);
        }
        System.out.println();
    }

    public static void main(String[] args) throws IOException {
        if (ONLINE_JUDGE){
            System.out.println();
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(System.out);
            //out = new PrintWriter("output.txt");
        }
        new CodeForces().runIt();
        out.flush();
        out.close();
        return;
    }

    static BufferedReader in;
    private StringTokenizer st;
    static PrintWriter out;

    static int pos;
    static String curInput = "";

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }


    void runIt() throws IOException {
        st = new StringTokenizer("");

//        int N = nextInt();
//        for (int i = 0; i < N; i++) {
//            runCase(i + 1);
//        }
        runCase(0);
        out.flush();
    }

}