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.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/*
 * @author Mahmoud Aladdin <aladdin3>
 *
 */
 
public class Main {
    public static void main (String[] args) throws java.lang.Exception {
		InputReader scan = new InputReader(System.in);
		PrintWriter writer = new PrintWriter(System.out, true);
		(new Main(scan, writer)).run();
		writer.close();
    }
    
    private InputReader jin;
    private PrintWriter jout;
    
    public Main(InputReader in, PrintWriter out) {
    	this.jin  = in;
    	this.jout = out;
    }
        
    public void run() throws Exception {
		String[] tok = new String[]{"1869", "6198", "1896", "1689", "1986", "1968", "1698"};
		boolean f1 = false, f6 = false, f8 = false, f9 = false, fz = true; 
		int zeros = 0; int rem = 0;
		StringBuffer newNum = new StringBuffer();
		String line = jin.token();
		for(int i = 0; i < line.length(); i++) {
			if(!f1 && line.charAt(i) == '1') {f1 = true; continue;}
			if(!f6 && line.charAt(i) == '6') {f6 = true; continue;}
			if(!f8 && line.charAt(i) == '8') {f8 = true; continue;}
			if(!f9 && line.charAt(i) == '9') {f9 = true; continue;}	
			if(fz && line.charAt(i) == '0') {zeros++; continue;}
			newNum.append(line.charAt(i));
			rem = (rem * 10 + (int)(line.charAt(i) - '0')) % 7;
			fz = false;
		}
		if(newNum.length() == 0) {
			jout.print(tok[0]); 
		} else {
			jout.print(newNum); jout.print(tok[rem]);
		}
		StringBuffer lst = new StringBuffer();
		while(zeros-- > 0) lst.append('0');
		jout.println(lst);
	}
}

 
class InputReader {
    private static final int bufferMaxLength = 1024;
    private InputStream in;
    private byte[] buffer;
    private int currentBufferSize;
    private int currentBufferTop;
    private static final String tokenizers = " \t\r\f\n";
    
    public InputReader(InputStream stream) {
        this.in = stream;
        buffer = new byte[bufferMaxLength];
        currentBufferSize = 0;
        currentBufferTop = 0;
    }
    
    private boolean refill() throws IOException {
        this.currentBufferSize = this.in.read(this.buffer);
        this.currentBufferTop = 0;
        return this.currentBufferSize > 0;
    }
    
    
    private Byte readChar() throws IOException {
        if(currentBufferTop < currentBufferSize) {
            return this.buffer[this.currentBufferTop++];
        } else {
            if(!this.refill()) {
                return null;
            } else {
                return readChar();
            }
        }
    }
    
    
    public String token() throws IOException {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) != -1));
        if(first == null) return null;
        tok.append((char)first.byteValue());
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) == -1)) {
            tok.append((char)first.byteValue());
        }
        return tok.toString();
    }
    
    public String line() throws IOException {
		Byte first;
		StringBuffer line = new StringBuffer();
		while ((first = readChar()) != null && (char)first.byteValue() != '\n') {
			line.append((char)first.byteValue());
		}
		return (first == null && line.length() == 0)? null : line.toString();
    }
    
    public Integer integer() throws NumberFormatException, IOException {
        String tok = token();
        return tok == null? null : Integer.parseInt(tok);
    }
    
}
