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.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nipuna Samarasekara
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    /////////////////////////////////////////////////////////////

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
   String S=in.readLine();
        boolean one=false,six=false,eit=false,nine=false;
   StringBuilder ans=new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i)=='1'&&(!one)){
                one=true;
                continue;
            }
           if(S.charAt(i)=='6'&&(!six)){
                six=true;
                continue;
            }
           if(S.charAt(i)=='8'&&(!eit)){
                eit=true;
                continue;
            }
           if(S.charAt(i)=='9'&&(!nine)){
                nine=true;
                continue;
            }
         ans.append(S.charAt(i));
        }
   String tt=ans.toString();
   long rem=0;
        for (int i = 0; i < tt.length(); i++) {
          int kk=(int)tt.charAt(i)-(int)'0';
        rem*=10;
         rem+=kk;
            rem%=7;
        }
    rem*=10000;
        rem%=7;
        if(rem==0)ans.append("1869");
       if(rem==6)ans.append("6189");
       if(rem==5)ans.append("1689");
       if(rem==4)ans.append("6198");
       if(rem==3)ans.append("1698");
       if(rem==2)ans.append("1986");
       if(rem==1)ans.append("8196");
     String aa=ans.toString();
       int zer=0;
        for (int i = 0; i < aa.length(); i++) {
         if(aa.charAt(i)!='0')break;
          zer++;

        }
        out.print(aa.substring(zer, aa.length()));
        for (int i = 0; i < zer; i++) {
            out.print("0");
        }
        out.println();
    }
}

class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }


}

