— 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.Scanner;

public class Main {
	
	private static long getTotal(int length) {
		
		long ans = 1;
		for (int i = 0;i < length / 2;i ++) {
			if (i == 0) {
				ans *= 9;
			} else {
				ans *= 10;
			}
		}
		return ans;
		
	}
	
	private static long getResult(int length , long p) {

		long temp = dfs(0 , length / 2 , 0 , p);
		return temp;
			
	}
	
	private static String reverse(String string) {
		
		StringBuilder builder = new StringBuilder();
		int i , length = string.length();
		for (i = length - 1;i >= 0;i --) {
			builder.append(string.charAt(i));
		}
		return builder.toString();
		
	}
	
	private static long dfs(int current , int length , long value , long p) {
		
		if (current == length) {
			String temp = Long.toString(value) + reverse(Long.toString(value));
			long number = Long.parseLong(temp) % p;
			return number;	
		} else {
			long result = 0;
			if (current == 0) {
				for (int i = 1;i < 10;i ++) {
					result = (result + dfs(current + 1 , length , value * 10 + i , p)) % p;
				}
			} else {
				for (int i = 0;i < 10;i ++) {
					result = (result + dfs(current + 1 , length , value * 10 + i , p)) % p;
				}
			}
			return result;
		}
		
	}
	
	private static long cnt = 0;
	private static long ans = 0;
	
	private static void getRemain(long k , int length , long p) {
		
		// 用length，里面的前k个元素
		cnt = 0;
		dfs2(0 , length / 2 , k , 0 , p);
		
	}
	
	private static void dfs2(int current , int length , long k , long value , long p) {
		
		if (cnt >= k) {
			return;
		}
		
		if (current == length) {
			cnt ++;
			String temp = Long.toString(value) + reverse(Long.toString(value));
			long number = Long.parseLong(temp) % p;
			ans = (ans + number) % p;
		} else {
			if (current == 0) {
				for (int i = 1;i < 10;i ++) {
					dfs2(current + 1 , length , k , value * 10 + i , p);
				}
			} else {
				for (int i = 0;i < 10;i ++) {
					dfs2(current + 1 , length , k , value * 10 + i , p);
				}
			}
		}
		
	}
	
	public static void main(String[] args) {	
		
		Scanner scan = new Scanner(System.in);
		
		int i;
		long k = scan.nextLong();
		long p = scan.nextLong();
		
		if (k <= 9) {
			for (i = 1;i <= k;i ++) {
				ans += (i * 10 + i);
			}
			ans %= p;
		} else {
			int length = 2;
			long total = getTotal(length);
			while (total <= k) {
				ans = (ans + getResult(length , p)) % p;
				length += 2;
				total += getTotal(length);
			}
			total -= getTotal(length);
			length -= 2;
			getRemain(k - total , length + 2 , p);
		}
		
		System.out.println(ans);
		
	}
	
	
}








	