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.awt.Point;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

/**
 * @author Jens Staahl
 */

public class B {

	// some local config
	// static boolean test = false ;
	private boolean test = System.getProperty("ONLINE_JUDGE") == null;
	static String testDataFile = "testdata.txt";
	// static String testDataFile = "testdata.txt";
	private static String ENDL = "\n";

	// Just solves the acutal kattis-problem
	ZKattio io;

	private void solve() throws Throwable {
		io = new ZKattio(stream);
		String s = io.getWord();
		boolean[] seen = new boolean[4];
		StringBuilder sb = new StringBuilder();
		int zerocnt = 0;
		for (int i = 0; i < s.length(); i++) {

			char ch = s.charAt(i);

			if (ch == '1' && !seen[0]) {
				seen[0] = true;
			} else if (ch == '6' && !seen[1]) {
				seen[1] = true;
			} else if (ch == '8' && !seen[2]) {
				seen[2] = true;
			} else if (ch == '9' && !seen[3]) {
				seen[3] = true;
			} else if (ch == '0') {
				zerocnt++;
			} else {
				sb.append(ch);
			}
		}
		StringBuffer z = new StringBuffer();
		for (int i = 0; i < zerocnt; i++) {
			z.append("0");

		}
		sb_ = sb;

		gen("1689", 0, new boolean[4], "", 0);

		out.write(sb.toString() + ss + z.toString() + "\n");
		out.flush();
	}

	String ss = null;
	StringBuilder sb_ = null;

	private void gen(String src, int i, boolean[] bs, String cur, int curmod) {
		if (i == 4) {
			String str = sb_.toString() + cur;
			int mod = str.charAt(0) - '0';
			for (int pos = 1; pos < str.length(); pos++) {
				mod *= 10;
				mod += (str.charAt(pos) - '0');
				mod %= 7;
			}

			if (mod == 0) {
				ss = cur;
			}
			return;
		}
		for (int j = 0; j < 4; j++) {
			if (!bs[j]) {
				bs[j] = true;
				gen(src, i + 1, bs, cur + src.charAt(j), curmod);
				bs[j] = false;
			}
		}
	}

	public static void main(String[] args) throws Throwable {
		new B().solve();
	}

	public B() throws Throwable {
		if (test) {
			stream = new FileInputStream(testDataFile);
		}
	}

	InputStream stream = System.in;
	BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));// outStream

	// =

	public class ZKattio extends PrintWriter {
		public ZKattio(InputStream i) {
			super(new BufferedOutputStream(System.out));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public ZKattio(InputStream i, OutputStream o) {
			super(new BufferedOutputStream(o));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public boolean hasMoreTokens() {
			return peekToken() != null;
		}

		public int getInt() {
			return Integer.parseInt(nextToken());
		}

		public double getDouble() {
			return Double.parseDouble(nextToken());
		}

		public long getLong() {
			return Long.parseLong(nextToken());
		}

		public String getWord() {
			return nextToken();
		}

		private BufferedReader r;
		private String line;
		private StringTokenizer st;
		private String token;

		private String peekToken() {
			if (token == null)
				try {
					while (st == null || !st.hasMoreTokens()) {
						line = r.readLine();
						if (line == null)
							return null;
						st = new StringTokenizer(line);
					}
					token = st.nextToken();
				} catch (IOException e) {
				}
			return token;
		}

		private String nextToken() {
			String ans = peekToken();
			token = null;
			return ans;
		}
	}
	// System.out;

}