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

public class Main {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	private static long mod = 1000000000 + 7;
	private static long mod1 = 1000000000 + 9;
	private static int MAX=1000001;
	private static int block;
	private static LinkedList<Integer> list[];
	private static boolean Visited[];
	private static int Array[];
	private static int count[];
	private static int result[];
	private static ArrayList<Integer> color[];
	
	private static void soln(){
		
		long k,p,ans=0,l=1,m=1,x,y;
		long a,b,c;
		k=nextInt();
		p=nextInt();
		while(k>0)
		{
			b=m;
			y=l*m*10;
			x=l;
			while(x>0)
			{
				a=x%10;
				x=(x-a)/10;
				y=y+a*b;
				b=b/10;
			}
			y=y%p;
			ans=ans+y;
			ans=ans%p;
			l++;
			if(l/m>=10)
				m=m*10;
			k--;
		}
		System.out.println(ans);
	}
	
	
	
	public static int dfs(int x,int k)
	{
		int sum=0;
		int size=0;
		Visited[x]=true;
		color[Array[x]].add(x);
		size=color[Array[x]].size();
		if(color[Array[x]].size()>k)
		{
			result[x]=color[Array[x]].get(size-k-1);
		}
		else
		{
			result[x]=-1;
		}
		
		for(Integer a:list[x])
		{
			if(!Visited[a])
			{
				dfs(a,k);
			}
		}
		color[Array[x]].remove(size-1);	
		return 0;
	}

	public static int bfs(int s,int d)
	{
		 //int count[] = new int[101];
		 //count[100]=-1;
		 //boolean Visited[] = new boolean[101];
		
		int c = 0;
		LinkedList<Integer> queue = new LinkedList<Integer>();
		
		Visited[s]=true;
		queue.add(s);
		
		
		while(queue.size()!=0)
		{
			
			s=queue.poll();
			c = count[s]+1;
			for(Integer x: list[s])
			{
				if(Visited[x]!=true)
				{
					Visited[x]=true;
					queue.add(x);
					count[x]=c;
				}
				if(x==d)
					return 0;
			}
		}
		
		return 0;
		
	}
	
	
	
	
	
	
	
	public static class disjointunion
	{
		int parent[],rank[],number[];
		int n;
	public	disjointunion(int n){
			rank = new int[n];
			parent = new int[n];
			number = new int[n];
			this.n=n;
			makeset();
		}
  void makeset()
  {	
	  for(int i=0;i<n;i++)
	  {
		parent[i]=i;
		number[i]=1;
	  }
  }
	int find(int i)
	{
		if(parent[i]!=i)
		{
			parent[i]=find(parent[i]);
		}
			return parent[i];
	}
	void union(int x,int y)
	{
		int xRoot , yRoot;
		xRoot = find(x);
		yRoot = find(y);
		if(xRoot==yRoot)
		return;
		
		if(rank[xRoot]<rank[yRoot])
		{
			parent[xRoot]=yRoot;
			number[yRoot] += number[xRoot];
			number[xRoot]=0;
		}
		if(rank[xRoot]>rank[yRoot])
		{
			parent[yRoot]=xRoot;
			number[xRoot] += number[yRoot];
			number[yRoot]=0;
		}
		if(rank[xRoot]==rank[yRoot])
		{
			parent[xRoot]=yRoot;
			number[yRoot] += number[xRoot];
			number[xRoot]=0;
			rank[yRoot]++;
		}
	}
	}	
		
	public static void main(String[] args) throws Exception 
	{
		new Thread(null,new Runnable()
		{
			@Override
			public void run() 
			{
				InputReader(System.in);
				pw = new PrintWriter(System.out);
				soln();
				pw.close();
			}
		},"1",1<<26).start();
	}

	public static void InputReader(InputStream stream1)
	{
		stream = stream1;
	}

	private static boolean isWhitespace(int c) 
	{
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c)
	{
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read()
	{
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) 
		{
			curChar = 0;
			try 
			{
				numChars = stream.read(buf);
			} catch (IOException e) 
			{
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nextInt()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do 
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nextLong() 
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do 
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do 
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() 
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do 
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) 
	{
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) 
		{
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n)
	{
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) 
		{
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr) 
	{
		for (int i = 0; i < arr.length; i++) 
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static boolean isSpaceChar(int c) 
	{
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	private static char nextChar() 
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1=(char)c;
		while(!isSpaceChar(c))
			c=read();
		return c1;
	}
	private interface SpaceCharFilter 
	{
		public boolean isSpaceChar(int ch);
	}
	
	
}