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

public class PracticeProblem
{
    /*
     * This FastReader code is taken from GeeksForGeeks.com
     * https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
     *
     * The article was written by Rishabh Mahrsee
     */
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader in = new FastReader();
    public static PrintWriter out = new PrintWriter(System.out);
    public static final int MOD = (int)1e9 + 7;

    public static void main(String[] args)
    {
        solve();

        out.close();
    }

    public static int subtract (int a, int b, int mod)
    {
        return (a % mod - b % mod + mod) % mod;
    }
    public static int[] pow;
    public static void solve()
    {
        int[] perm = {1869, 1968, 1689, 6198, 1698, 1986, 1896}; // Each number x is in the index x % 7

        char[] inputNum = in.nextLine().toCharArray();
        List<Character> num = new ArrayList<>();
        int zeroCount = 0;

        for (int i = 0; i < inputNum.length; i++)
        {
            if (inputNum[i] != '0')
                num.add(inputNum[i]);
            else
                zeroCount++;
        }
        num.remove(new Character('1'));
        num.remove(new Character('6'));
        num.remove(new Character('8'));
        num.remove(new Character('9'));

        int modOfOtherNums = 0;

        for (int i = 0; i < num.size(); i++)
        {
            modOfOtherNums *= 10;
            modOfOtherNums += num.get(i)-'0';
            modOfOtherNums %= 7;
        }

        modOfOtherNums *= 10000;
        modOfOtherNums %= 7;


        for (char c : num) out.print(c);
        out.print(perm[(7 - modOfOtherNums) % 7]);
        for (int i = 0; i < zeroCount; i++) out.print(0);
    }

}
