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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ATailouloute
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        QuickScanner in = new QuickScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, QuickScanner in, PrintWriter out) {
            String s = in.nextString();
            int z = 0;
            boolean[] a = new boolean[4];
            List<Integer> others = new ArrayList<>();
            StringBuffer sb = new StringBuffer();
            int x = 0;
            for (int i = 0; i < s.length(); i++) {
                if (!a[0] && s.charAt(i) == '1') a[0] = true;
                else if (!a[1] && s.charAt(i) == '6') a[1] = true;
                else if (!a[2] && s.charAt(i) == '8') a[2] = true;
                else if (!a[3] && s.charAt(i) == '9') a[3] = true;
                else if (s.charAt(i) == '0') z++;
                else {
                    sb.append(s.charAt(i));
                    x = (x * 10 + (s.charAt(i) - '0')) % 7;
                }
            }
            if (!a[0] || !a[1] || !a[2] || !a[3]) {
                out.print(0);
                return;
            }
            for (int i = 0; i < 4 + z; i++) {
                x = (x * 10) % 7;
            }
            String[] perms = new String[]{"9681", "8961", "9816", "6891", "8691", "9861", "8196"};
            String res = "";
            if (sb.length() != 0) {
                res = sb + StringUtils.repeat("0", z) + perms[(7 - x) % 7];
            } else {
                res = perms[0] + StringUtils.repeat("0", z);
            }
            out.println(res);
        }

    }

    static class StringUtils {
        public static String repeat(String s, int times) {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < times; i++) {
                sb.append(s);
            }
            return sb.toString();
        }

    }

    static class QuickScanner {
        BufferedReader br;
        StringTokenizer st;
        InputStream is;

        public QuickScanner(InputStream stream) {
            is = stream;
            br = new BufferedReader(new InputStreamReader(stream), 32768);
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        String nextString() {
            return nextToken();
        }

    }
}

