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.*;
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Main
{
    static StringTokenizer st=new StringTokenizer("");
    static BufferedReader br;
    ///////////////////////////////////////////////////////////////////////////////////
    
    public static void main(String args[]) throws FileNotFoundException, IOException, Exception
    {
        //Scanner in =new Scanner(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        //Scanner in=new Scanner(System.in);
        br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //StringTokenizer st;//=new StringTokenizer(br.readLine());
        //////////////////////////////////////////////////////////////////////////////////////
        
        int p[]={1869,6198,1896,1689,1986,1968,1698};
        int cnt[]=new int[10];
        String s=ns();
        for(int i=0;i<s.length();i++) cnt[s.charAt(i)-'0']++;
        cnt[1]--;
        cnt[9]--;
        cnt[6]--;
        cnt[8]--;
        int num=0;
        for(int i=1;i<=9;i++)
        {
            while(cnt[i]!=0)
            {
                out.print(i);
                num=(num*10+i)%7;
                cnt[i]--;
            }
        }
        out.print(p[num]);
        for(int i=0;i<cnt[0];i++)out.print(0);
        //////////////////////////////////////////////////////////////////////////////////////
	out.close();
    }
    
    
    
    
    ///////////////////////////////////////////////////////////////////////////////
    static public class pair implements Comparable<pair>
    {
        int ind,cap;
        pair(){ind=0;cap=0;}
        pair(int first,int second){ind=first;cap=second;}
        public int compareTo(pair o) {
            return cap-o.cap;
        }
    }
    static public class triple implements Comparable<triple>
    {
        int ind,price,cap;
        triple(){ind=0;cap=0;price=0;}
        triple(int f,int s,int t){ind=f;cap=s;price=t;}
        public int compareTo(triple o) {
            return o.price-price;
        }
        
    }
    public static Integer ni() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }
    public static BigInteger nb()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return BigInteger.valueOf(Long.parseLong(st.nextToken()));
    }
    public static Long nl() throws Exception
    {
        if(!st.hasMoreTokens())
            st=new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }
    public static Double nd()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return Double.parseDouble(st.nextToken());
    }
    public static String ns()throws Exception
    {
        if(!st.hasMoreElements())
            st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}