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.text.*;
import java.util.*;
import static java.lang.Math.*;
import java.awt.Point;
import java.io.*;
import static java.util.Arrays.*;
import java.util.Map.Entry;

public class Main {
	static String[] mod = { "1869", "6198", "1896", "9186", "9168", "6189",
			"8691" };

	public static void main(String[] args) throws Exception {
		String in = n();
		long[] dp = new long[10];
		for (int i = 0; i < in.length(); i++)
			dp[in.charAt(i) - '0']++;
		dp[1]--;
		dp[6]--;
		dp[9]--;
		dp[8]--;
		if (dp[1] < 0 || dp[6] < 0 || dp[9] < 0 || dp[8] < 0) {
			System.out.println("0");
			return;
		}
		int rem = 0;
		for (int i = 9; i > 0; i--)
			if (dp[i] > 0) {
				StringBuilder s = new StringBuilder((int) dp[i]);
				while (dp[i]-- > 0) {
					s.append(((char) (i + '0')));
					rem = 10 * rem + i;
					rem %= 7;
				}
				out.print(s.toString());
			}
		if (rem < 0)
			rem += 7;
		out.print(mod[rem]);
		while (dp[0]-- > 0) {
			out.print('0');
		}
		out.println();
		out.flush();
	}

	static double round(double d, int n) {
		long x = 1;
		while (n-- > 0) {
			x *= 10;
		}
		return (Math.round(d * x) / (double) x);
	}

	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;
	static boolean hasMore;

	/** has input */
	static boolean hi() {
		return hasMore;
	}

	static void init() {
		in = new BufferedReader(new InputStreamReader(System.in));
		st = new StringTokenizer("");
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));
		hasMore = true;
	}

	static {
		init();
	}

	static double nd() throws NumberFormatException, IOException {
		return Double.parseDouble(n());
	}

	static String n() throws IOException {
		while (hasMore && !st.hasMoreTokens()) {
			String nextLine = in.readLine();
			if (nextLine == null)
				hasMore = false;
			else
				st = new StringTokenizer(nextLine);
		}
		return hasMore ? st.nextToken() : null;
	}

	static int ni() throws NumberFormatException, IOException {
		return Integer.parseInt(n());
	}

	static long nl() throws NumberFormatException, IOException {
		return Long.parseLong(n());
	}

	static void rev(long[] a) {
		for (int s = 0, t = a.length - 1; s < t; s++, t--) {
			long tempLong = a[s];
			a[s] = a[t];
			a[t] = tempLong;
		}
	}

	static void rev(int[] a) {
		for (int s = 0, t = a.length - 1; s < t; s++, t--) {
			int tempLong = a[s];
			a[s] = a[t];
			a[t] = tempLong;
		}
	}

	static void rev(String[] a) {
		for (int s = 0, t = a.length - 1; s < t; s++, t--) {
			String tempLong = a[s];
			a[s] = a[t];
			a[t] = tempLong;
		}
	}
}
