— 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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.security.KeyStore.Entry;
import java.time.temporal.JulianFields;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.JLabel;

public class answertillD {
	static int minn;

	static class pair implements Comparable<pair> {
		int u;
		int v;

		public pair(int uo, int vo) {
			u = uo;
			v = vo;

		}

		@Override
		public String toString() {
			return "pair [u=" + u + ", v=" + v + "]";
		}

		@Override
		public int compareTo(pair e) {
			if (u == e.u && v == e.v)
				return 0;
			if (u > e.u || e.u > u)
				return u - e.u;
			else
				return 1;
		}
	}

	static class edge implements Comparable<edge> {
		int u;
		int v;
		int w;

		@Override
		public String toString() {
			return "edge [u=" + u + ", v=" + v + ", w=" + w + "]";
		}

		public edge(int uo, int vo, int wo) {
			u = uo;
			v = vo;
			w = wo;
		}

		@Override
		public int compareTo(edge e) {
			// TODO Auto-generated method stub
			return w - e.w;
		}
	}

	public static long power(long x, long y) {
		long ans = 1;
		while (y-- > 0) {
			if (ans <= 1e18 / x)
				ans *= x;
			else {
				ans = Long.MAX_VALUE;
				break;
			}
		}
		return ans;
	}

	public static char[][] reb() {
		int n = smallArr.length;
		char[][] arr = new char[n][n];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				arr[i][j] = smallArr[n - j - 1][i];

		return arr;
	}

	static int[] Arr, cost, level;
	static char[][] smallArr;
	static boolean[][] memo;
	static int n;
	static long S;
	static final int VISITED = 2, EXPLORED = 1, UNVISITED = 0;
	static ArrayList<Integer>[] adjList;
	static boolean[] visited, adjMat[];
	static int V, E;

	static long bfs(String str, int k) {
		Queue<String> q = new LinkedList<String>();
		q.add(str);
		HashSet<String> hs = new HashSet<String>();
		hs.add(str);
		HashMap<String, Integer> hm = new HashMap<String, Integer>();
		hm.put(str, 0);
		long ans = 0;
		while (k > 0 && !q.isEmpty()) {
			String u = q.remove();
			for (int v = 0; v < u.length(); v++) {
				String sam = u.substring(0, v) + u.substring(v + 1);
				if (!hm.containsKey(sam)) {
					int x = hm.get(u) + 1;
					hm.put(sam, x);
					k--;
					ans += x;
					if (k == 0)
						break;
					q.add(sam);
				}
			}

		}
		if (k != 0)
			return -1;
		return ans;

	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		return GCD(b, a % b);
	}

	public static long powerlog(long x, long y, int mod) {
		long res = 1; // Initialize result
		while (y > 0) {
			if ((y & 1) == 1)
				res = (res * x);
			// res %= mod;
			y = y >> 1; // y = y/2
			x = (x * x);
			// x %= mod;
		}
		return res;
	}

	public static String rev(String str) {
		StringBuilder sb = new StringBuilder();
		for (int i = str.length() - 1; i >= 0; i--) {
			sb.append(str.charAt(i));
		}
		return sb + "";
	}

	public static boolean checj(int numa, int b, int a, int n, int k) {
		int numb = n - numa;
		if (k % a == 0) {
			if (k / a - 1 < numa)
				return false;
		} else {
			if (k / a < numa)
				return false;
		}
		k -= numa * a;
		if (k % b == 0) {
			if (k / b - 1 < numb)
				return false;
		} else {
			if (k / b < numb)
				return false;
		}
		return true;
	}

	static int mod;
	static String ans;
	static int[] arr;

	public static boolean dp(int idx, int rem) {
		if (idx == n)
			return rem % mod == 0;

		if (!memo[idx][rem])
			return memo[idx][rem];
		if (cost[idx] != -1) {
			arr[idx] = cost[idx];
			return memo[idx][rem] = dp(idx + 1, (int) ((rem + cost[idx] * powerlog(10, n - 1 - idx, mod)) % mod));

		}
		boolean flag = false;
		for (int i = 0; i < 10; i++) {
			if (idx == 0 && i == 0)
				continue;
			arr[idx] = i;
			flag = dp(idx + 1, (int) ((rem + i * powerlog(10, n - idx - 1, mod)) % mod));
			if (flag)
				break;
		}

		return memo[idx][rem] = flag;
	}

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int p = sc.nextInt();
		long ans = 0;
		long sum = 0;
		int shift1 = 0;
		int shift2 = 0;
		int shift3 = 0;
		int shift4 = 0;
		int shift5 = 0;
		outer: for (int i = 0; i < 10; i++) {
			if (i == 1)
				shift1++;
			long r = powerlog(10, 0, p) * i + powerlog(10, 11, p) * i;
			sum += r;
			// sum%=p;
			for (int j = 0; j < 10; j++) {
				if (j == 1&&i==0)
					shift2++;
				int sumssss = shift1;
				long q = powerlog(10, 0 + sumssss, p) * j + powerlog(10, 9 + sumssss, p) * j;
				sum += q;
				// sum%=p;
				for (int k = 0; k < 10; k++) {
					if (k == 1&&j==0&&i==0)
						shift3++;
					int sumsss = shift1 + shift2;
					long o = powerlog(10, 0 + sumsss, p) * k + powerlog(10, 7 + sumsss, p) * k;
					sum += o;
					// sum%=p;
					for (int l = 0; l < 10; l++) {
						if (l == 1&&k==0&&j==0&&i==0)
							shift4++;
						int sumss = shift1 + shift2 + shift3;
						long z = powerlog(10, 0 + sumss, p) * l + powerlog(10, 5 + sumss, p) * l;
						sum += z;
						// sum%=p;
						for (int m = 0; m < 10; m++) {
							if (m == 1&&l==0&&k==0&&j==0&&i==0)
								shift5++;
							int sums = shift1 + shift2 + shift3 + shift4;
							long y = powerlog(10,  sums, p) * m + powerlog(10, 3 + sums, p) * m;
							sum += y;
							// sum%=p;
							for (int u = 0; u < 10; u++) {
								int sumsh = shift1 + shift2 + shift3 + shift4 + shift5;
								long x = powerlog(10, sumsh, p) * u + powerlog(10, 1 + sumsh, p) * u;
								sum += x;
							//	System.out.println(sumsh+" "+sum);

								ans += (sum % p);
								sum -= x;
								ans %= p;
								if (sumsh == 0 && u == 0)
									continue;
								n--;
								if (n == 0)
									break outer;

							}
							sum -= y;
						}
						sum -= z;
					}
					sum -= o;
				}
				sum -= q;
			}
			sum -= r;
		}
		pw.print(ans);
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}
