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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class C {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;
	public static void main(String[] args) throws IOException {
		begin();
		solve();
		end();
	}
	private static void end() {
		out.close();
	}
	private static void solve() throws IOException {
		int []d = {9618,1869,1896,1968,6891,6189,6819,9861,9816,8619,8691,6981,1698,1689,6198,8961,8916,1986,9186,6918,8169,8196,9168,9681};
		int []cnt = new int [10];
		char []s = next().toCharArray();
		for (int i = 0; i < s.length; i++) {
			cnt[s[i]-48]++;
		}
		cnt[1]--;
		cnt[6]--;
		cnt[8]--;
		cnt[9]--;
		char []a = new char [s.length-4];
		int size = 0;
		for (int i = 0; i < 10; i++) {
			while (cnt[i]--> 0)
				a[size++] = (i+"").charAt(0);
		}
		int id = -1;
		for (int i = 0; i < size; i++) {
			if (a[i] > '0'){
				char p = a[i];
				a[i] = a[0];
				a[0] = p;
				id = i;
				break;
			}
		}
		if (id == -1){
			write("1869");
			for (int i = 0; i < size; i++) {
				write(a[i]);
			}
			return;
		}
		int mod = 0;
		for (int i = 0; i < size; i++) {
			mod  = (10*mod+a[i]-48)%7;
		}
		mod *= 10000;
		for (int i = 0; i < d.length; i++) {
			if ((mod+d[i])%7 == 0){
				for (int j = 0; j < a.length; j++) {
					write(a[j]);
				}
				write(d[i]);
				return;
			}
		}
	}
	private static long nextLong() throws  IOException {
		return Long.parseLong(next());
	}
	private static void writeln(Object t) {
		out.println(t);
	}
	private static void write(Object t) {
		out.print(t);
	}
	private static int nextInt() throws  IOException {
		return Integer.parseInt(next());
	}
	private static String next() throws IOException {
		while (!st.hasMoreElements())
			st = new StringTokenizer(in.readLine());
		
		return st.nextToken();
	}
	private static void begin() {
		out = new PrintWriter(new OutputStreamWriter(System.out));
		st = new StringTokenizer("");
		in = new BufferedReader(new InputStreamReader(System.in));
	}

}
