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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
	static char [] arr;
	static int mod;
	static boolean fin;
	static void print(int idx, int m, boolean used1, boolean used6, boolean used8, boolean used9){
		if(idx == 0)
		{
			if(m == mod)
				fin = true;
			return;
		}
		if(!fin && !used1){
			arr[4-idx] = '1';
			print(idx-1, (m * 10 + 1)%7, true, used6, used8, used9);
		}
		if(!fin && !used6){
			arr[4-idx] = '6';
			print(idx-1, (m * 10 + 6)%7, used1, true, used8, used9 );
		}
		if(!fin  && !used8){
			arr[4-idx] = '8';
			print(idx-1, (m * 10 + 8)%7, used1, used6, true, used9 );
		}
		if(!fin && !used9){
			arr[4-idx] = '9';
			print(idx-1, (m * 10 + 9)%7, used1, used6, used8, true);
		}
	}
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char[] c = sc.next().toCharArray();
		int[] occ = new int[10];
		for (int i = 0; i < c.length; i++) {
			occ[c[i] - '0']++;
		}
		occ[1]--;
		occ[6]--;
		occ[8]--;
		occ[9]--;
		mod = 0;
		for (int i = 1; i < occ.length; i++) {
			while (occ[i]-- > 0) {
				out.print(i);
				mod = (mod * 10 + i) % 7;
			}
		}
		mod = (mod * 10000) % 7;
		mod = (7-mod)%7;
		arr = new char[4];
		fin = false;
		print(4, 0, false, false, false, false);
		out.print(arr);
		while (occ[0]-- > 0)
			out.print("0");
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader bf;
		StringTokenizer st;

		public Scanner(InputStream i) {
			bf = new BufferedReader(new InputStreamReader(i));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(bf.readLine());
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}
}