— 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.*;
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;


public class Main {
    static class node
    {
        int x;
        int y;
    }
    static class cmp1 implements Comparator<node>
    {
        @Override
        public int compare(node a,node b)
        {
            return a.x-b.x;
        }
    }
    public static void main(String[] args) throws IOException
    {
        //StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        FastScanner sc = new FastScanner();
        //Scanner sc=new Scanner(System.in);
        long k=sc.nextLong(),p=sc.nextLong();
        long ans = 0;
        long b[]=new long[11];
        for(long i = 1; i <= k ; i ++) {
            long tmp = i;
            int cnt = 0;
            while(tmp > 0)
            {
                b[cnt++] = tmp % 10;
                tmp /= 10;
            }
            long xx = 1;
            for(int j = 0; j < cnt; j ++)
            {
                tmp = tmp*10 + b[j];
                xx *= 10;
            }
            cnt = (int)i;
            ans += cnt*xx+tmp;
            ans %= p;
        }
        out.println((ans+p)%p);

        out.flush();




    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        private FastScanner() {
            try	{
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }
        private boolean hasNextToken()
        {
            if(st.countTokens()!=StreamTokenizer.TT_EOF)
            {
                return true;
            }
            else
                return false;
        }
        private String next() {
            if (st.hasMoreTokens())	return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }
        private BigInteger nextBigInteger(){return new BigInteger(next());}
        private BigDecimal nextBigDecimal(){return new BigDecimal(next());}
        private  int nextInt() {return Integer.parseInt(next());}
        private long nextLong() {return Long.parseLong(next());}
        private double nextDouble() {return Double.parseDouble(next());}
        private String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
        private int[] nextIntArray(int n) {
            int[] a = new int[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        private long[] nextLongArray(int n){
            long[] a = new long[n];
            for(int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
        private double[] nextDoubleArray(int n){
            double[] a = new double[n];
            for(int i = 0; i < n; i++) a[i] = nextDouble();
            return a;
        }
        private char[][] nextGrid(int n, int m){
            char[][] grid = new char[n][m];
            for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
            return grid;
        }
        private void sort(int arr[])
        {
            int cnt[]=new int[(1<<16)+1];
            int ys[]=new int[arr.length];
            for(int j=0;j<=16;j+=16){
                Arrays.fill(cnt,0);
                for(int x:arr){cnt[(x>>j&0xFFFF)+1]++;}
                for(int i=1;i<cnt.length;i++){cnt[i]+=cnt[i-1];}
                for(int x:arr){ys[cnt[x>>j&0xFFFF]++]=x;}
                { final int t[]=arr;arr=ys;ys=t;}
            }
            if(arr[0]<0||arr[arr.length-1]>=0)return;
            int i,j,c;
            for(i=arr.length-1,c=0;arr[i]<0;i--,c++){ys[c]=arr[i];}
            for(j=arr.length-1;i>=0;i--,j--){arr[j]=arr[i];}
            for(i=c-1;i>=0;i--){arr[i]=ys[c-1-i];}
        }
    }

}


