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

public class MainClass
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        HashMap<Integer, String> h = new HashMap<>();
        h.put(7, "1869");
        h.put(1, "1968");
        h.put(2, "1689");
        h.put(3, "6198");
        h.put(4, "1698");
        h.put(5, "1986");
        h.put(6, "1896");
        int[] count = new int[10];
        for (int i=0;i<s.length();i++)
            count[s.charAt(i) - '0']++;
        count[1]--;
        count[6]--;
        count[8]--;
        count[9]--;
        boolean flag = false;
        for (int i=1;i<10;i++)
        {
            if (count[i] > 0)
            {
                flag = true;
                break;
            }
        }
        if (!flag)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(h.get(7));
            for (int i=0;i<count[0];i++)    stringBuilder.append("0");
            System.out.println(stringBuilder);
        }
        else
        {
            StringBuilder stringBuilder = new StringBuilder();
            int rem = 0;
            int[] C = new int[s.length() + 1];
            C[0] = 1;
            for (int i=1;i<=s.length();i++)
                C[i] = (3 * C[i - 1]) % 7;
            int c = 4;
            for (int i=0;i<10;i++)
            {
                for (int j=0;j<count[i];j++)
                {
                    stringBuilder.append(i);
                    rem = (rem + (C[c++] * i) % 7) % 7;
                }
            }
            stringBuilder.reverse();
            stringBuilder.append(h.get(7 - rem));
            System.out.println(stringBuilder);
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}
