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

//@SuppressWarnings("unused")
public class A {

	private final static boolean autoflush = false;

	public A () {
		char [] D = new char [] { '1', '6', '8', '9' };
		int [][] P = permutations(4);

		int [] Z = new int [24]; int z = 0;
		for (int [] p : P) {
			String s = "";
			for (int q : p)
				s += D[q];
			Z[z++] = Integer.parseInt(s);
		}

		int [] R = new int [7];
		for (int i : rep(7))
			for (int r : Z)
				if (r % 7 == i)
					R[i] = r;
		//print(R);

		char [] Q = sc.nextChars();
		StringBuilder res = new StringBuilder();
		int A = 0, B = 0;
		boolean [] C = new boolean [4];

		out: for (int q : Q) {
			for (int i : rep(4))
				if (!C[i] && D[i] == q) {
					C[i] = true; continue out;
				}
			q -= '0';
			if (q == 0)
				++B;
			else {
				A = (10 * A + q) % 7;
				res.append(q);
			}
		}

		A = (10000 * A) % 7;
		res.append(R[(7-A)%7]);
		for (int i : rep(B))
			res.append(0);

		exit(res);
	}

	///////////////////////////////////////////////////////////////////////////
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static int [][] permutations(int N) {
		if (N == 1)
			return new int [][] {{ 0 }};

		int [][] P = permutations(N-1);

		int [][] Q = new int[N * P.length][N];
		for (int i = 0, n = 0; i < P.length; ++i)
			for (int j = 0; j < N; ++j, ++n) {
				for (int k = 0; k < N-1; ++k) {
					int x = P[i][k];
					Q[n][k] = x < j ? x : x+1;
				}
				Q[n][N-1] = j;
			}
		return Q;
	}
	////////////////////////////////////////////////////////////////////////////////////
	private final static MyScanner sc = new MyScanner();
	private static class MyScanner {
		public String next() { newLine(); return line[index++]; }
		public char [] nextChars() { return next ().toCharArray (); }
		//////////////////////////////////////////////
		private boolean eol() { return index == line.length; }
		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error (e);
			}
		}
		private final java.io.BufferedReader r;
		private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
		private MyScanner (java.io.BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private String [] line;
		private int index;
		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}
	}
	private static void print (Object o, Object... a) { printDelim(" ", o, a); }
	private static void printDelim (String delim, Object o, Object... a) { pw.println(build(delim, o, a)); }
	private static void exit (Object o, Object... a) { print(o, a); exit(); }
	private static void exit() {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static String build (String delim, Object o, Object... a) {
		StringBuilder b = new StringBuilder();
		append(b, o, delim);
		for (Object p : a)
			append(b, p, delim);
		return b.substring(delim.length());
	}
	private static void append(StringBuilder b, Object o, String delim) {
		if (o.getClass().isArray()) {
			int L = java.lang.reflect.Array.getLength(o);
			for (int i = 0; i < L; ++i)
				append(b, java.lang.reflect.Array.get(o, i), delim);
		} else if (o instanceof Iterable<?>)
			for (Object p : (Iterable<?>)o)
				append(b, p, delim);
		else
			b.append(delim).append(o);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static void start() { t = millis(); }
	private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out, autoflush);
	private static long t;
	private static long millis() { return System.currentTimeMillis(); }
	public static void main (String[] args) { new A(); exit(); }
}
