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

/**
 *  
 * @author akashvermaofskt
 * Coding is love <3!
 */



public class B {
    static long A[]=new long[100000];
    static long p;
    
    static String rev(String s){
        String ans="";
        for (int i = s.length()-1; i >= 0; i--) {
            ans+=s.charAt(i);
        }
        
        return ans;
    }
    
    static void fill(){
       BigInteger bi;
        
        
        for (int i = 1; i <= 100000; i++) {
            bi=new BigInteger(i+""+rev(i+""));
            A[i-1]=bi.mod(BigInteger.valueOf(p)).longValue();
        }
    }
    
    public static void main(String args[]) {
        try {
            int k=nextInt();
            p=nextLong();
            fill();
            //System.out.println(""+Arrays.toString(A));
            long ans=0;
            
            for (int i = 0; i <k; i++) {
                ans+=A[i];
                ans=ans%p;
            }
            
            bw.write(ans+"\n");
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    //TEMPLATE
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringTokenizer st = null;
    
    static String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    
    static int nextInt() {
        return Integer.parseInt(next());
    }
    
    static long nextLong() {
        return Long.parseLong(next());
    }

    static double nextDouble() {
        return Double.parseDouble(next());
    }
    
    static class Pair{
        public int first;
        public int second;

        public Pair(int first, int second){
            this.first = first;
            this.second = second;
            }
            @Override
            public String toString() {
            return "Pair [first=" + first + ", second=" + second + "]";
            }
    }

    static Comparator csort=new Comparator<Pair>(){
                    public int compare(Pair a, Pair b) {
                        if(a.first < b.first)
                        return -1;
                        else if (a.first > b.first)
                        return 1;
                        else
                        return 0;
                    }
                };
    
}
