— Thanks a lot for today.

— I experienced so many great things.

— You gave me memories like dreams... But I have to leave now...

— One last request, can you...

— Help me solve a Codeforces problem?

— ......

— What?

Chtholly has been thinking about a problem for days:

If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.

Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.

Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!

Input

The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).

Output

Output single integer — answer to the problem.

Examples

Input

2 100


Output

33


Input

5 30


Output

15

Note

In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.

In the second example, <image>.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskB {
        int[] pow = new int[12];

        public void solve(int testNumber, InputReader in, FastWriter out) {
            int k = in.nextInt();
            int mod = in.nextInt();

            pow[0] = 1;
            for (int i = 1; i < pow.length; ++i)
                pow[i] = NumberTheory.multiply(pow[i - 1], 10, mod);

//        long start = 1, end = start * 10;
//        int j = 1;
//        int res = 0;
//        while (k > 0) {
//            for (long i = start; i < end && k > 0; i++, k--) {
//                res = add(res, multiply((int)(i%mod), pow[j], mod), mod);
//                long ii = i;
//                int r = j - 1;
//                while (ii != 0) {
//                    res = add(res, multiply((int) ii % 10, pow[r], mod), mod);
//                    r--;
//                    ii /= 10;
//                }
//                start *= 10;
//                end *= 10;
//            }
//            j++;
//        }
//
//        out.println(res);


            int[] kk = {k};
            int res = 0;
            int n = 1;
            do {
                int[] a = new int[n];
                res = NumberTheory.add(res, compute(0, a, n, kk, mod), mod);
                n++;
            } while (kk[0] > 0);
            out.println(res);
        }

        private int compute(int pos, int[] a, int n, int[] k, int mod) {
            if (k[0] <= 0) return 0;

            if (pos == n) {
                int res = 0;
                for (int i = n - 1; i >= 0; i--) {
                    int temp = NumberTheory.multiply(a[i], NumberTheory.add(pow[i], pow[2 * n - i - 1], mod), mod);
                    res = NumberTheory.add(res, temp, mod);
                }
                k[0]--;
                return res;
            }
            int res = 0;
            for (int digit = (pos == 0) ? 1 : 0; digit < 10 && k[0] > 0; ++digit) {
                a[pos] = digit;
                res = NumberTheory.add(res, compute(pos + 1, a, n, k, mod), mod);
            }
            return res;
        }

    }

    static class FastWriter extends PrintWriter {
        public FastWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public FastWriter(Writer writer) {
            super(writer);
        }

        public FastWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

    }

    static class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return tokenizer.nextToken();
        }

        public Integer nextInt() {
            return Integer.valueOf(next());
        }

    }

    static class NumberTheory {
        public static int multiply(int a, int b, int mod) {
            long product = a * (long) b;
            if (product >= mod)
                product %= mod;
            return (int) product;
        }

        public static int add(int a, int b, int mod) {
            long sum = a + (long) b;
            if (sum >= mod)
                sum %= mod;
            return (int) sum;
        }

    }
}

