— 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 ≤ 10^5, 1 ≤ p ≤ 10^9).


-----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, $(11 + 22 + 33 + 44 + 55) \operatorname{mod} 30 = 15$.

Difficulty: interview

Starter code:

Solutions:
from itertools import *


k, p = list(map(int, input().split()))
ss = 0
for i in range(1, k + 1):
    s = str(i)
    num = int(s + ''.join(reversed(s)))
    ss += num
    ss %= p
print(ss)


import sys
sys.setrecursionlimit(100000000)
# def input(): return sys.stdin.readline()[:-1]
def iin(): return int(input())
def impin(): return list(map(int, input().split()))
def irrin(): return [int(x) for x in input().split()]
def imrin(n): return [int(input()) for _ in range(n)]


s = 0
k, p = impin()
for i in range(1, k+1):
    s = (s+i*10**len(str(i))+int(str(i)[::-1]))%p
print(s)


# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

"""
created by shhuan at 2017/12/2 22:09

"""

K, P = map(int, input().split())

ans = 0
for v in range(1, K+1):
    x = str(v)
    x = x + x[::-1]
    x = int(x)
    ans += x
    ans %= P
print(ans)

k, p = list(map(int, input().split()))
c = 0
for i in range(1, k + 1):
	s = str(i)
	s_ = s[::-1]
	c += int(s + s_)
	c %= p
print(c)

k, p = map(int, input().split())
ans = 0
for i in range(1, k+1):
    n = i
    n = str(i) + str(i)[::-1]
    n = int(n)
    ans += n
print(ans%p)

k,p = list(map(int,input().split()))

i = 1
S = 0
while k>0:
    S += int(str(i)+str(i)[::-1])
    i += 1
    k -= 1
print(S%p)


K, P = list(map(int, input().split()))
sums = 0

for i in range(1, K+1):
    sums += int(str(i)+str(i)[::-1])
    sums %= P
print(sums)


k, p = map(int, input().split())

def zcy(n):
    ans = str(n) + str(n)[::-1]
    return int(ans)

ans = 0
for i in range(1, k + 1):
    ans = (ans + zcy(i)) % p

print(ans)




def main():
    k, p = map(int, input().split())
    s = 0
    for i in range(1, k + 1):
        r = str(i)
        w = r[::-1]
        n = int(r + w)
        s += n

    print(s % p)




def __starting_point():
    try:
        main()
    except KeyboardInterrupt:
        pass
__starting_point()

k, p = list(map(int, input().strip().split()))


vsota = 0

count = 0

x = 1
while True:
    u = int(str(x) + str(x)[::-1])
    vsota += u
    count += 1
    if count == k:
        break
    x += 1
print(vsota % p)

        



k, p = [int(x) for x in input().split()]

s = 0

for i in range(k):
    n = str(i + 1)
    n += n[::-1]
    s = (s + int(n)) % p

print(s)


n=input()
x,y=n.split()
y=int(y)
su=0
for i in range(1,int(x)+1):
    z=int(str(i)+str(i)[::-1])
    su+=z
    su%=y
print(su)


k, p = list(map(int, input().split()))
ans = 0
for n in range(1, k + 1):
    x = n
    y = 0
    z = n
    while 0 < x:
        y *= 10
        y += x % 10
        x //= 10
        z *= 10
    z += y
    ans += z
    ans %= p
print(ans)


k, p = list(map(int, input().split()))
s = 0
for i in range(1, k+1):
    s = (s+int(str(i)+str(i)[::-1]))%p
print(s)


maxk = 100001

n = 1
zcy = []
while len(zcy) <= maxk:
    zcy.append(int(str(n) + str(n)[::-1]))
    n += 1

s = input().strip().split()
k = int(s[0])
p = int(s[1])
ans = 0

for i in range(k):
    ans = (ans + zcy[i]) % p

print(ans)


k, p = map(int, input().split())
z = 9
res = 0
mn = 11
i = 1
def x(i):
	return int(str(i)[::-1])
for i in range(1, k + 1):
	if i < 10:
		res += i * 11
	elif i < 100:
		res += i * 100 + x(i)
	elif i < 10**3:
		res += i * 10**3 + x(i)
	elif i < 10**4:
		res += i * 10**4 + x(i)
	elif i < 10**5:
		res += i * 10**5 + x(i)
	else:
		res += i * 10**6 + x(i)
print(res % p)

def get_zcy(a):
    s = str(a)
    ln = len(s)
    return a * 10 ** ln + int(s[::-1])


k, p = list(map(int, input().split()))

print(sum([get_zcy(x) for x in range(1, k + 1)]) % p)


import math
A = input().split()
k = int(A[0])
p = int(A[1])
palin = [0]*k
for i in range (0,k):
    digit = int(math.log(i+1) // math.log(10))
    L = list(str(i+1))
    M = L[::-1]
    fin = L+M
    num = ''.join(fin)
    palin[i] = int(num)
sum = 0
for i in range (0,k):
    sum = (sum + palin[i])%p
print(sum)

k, p = list(map(int, input().split()))

def cd(n):
	res = 0
	while n > 0:
		res += 1
		n //= 10
	return res

def rev(n):
	res = 0
	while n > 0:
		res*= 10
		res += n % 10
		res %= p
		n //= 10
	return res

ans = 0
for i in range(1, k + 1):
	ans += i * 10**cd(i) + rev(i)
	ans %= p
print(ans)

k, p = list(map(int, input('').strip().split()))
answer = 0
before = 0
for i in range(k):
    if before == 0:
        before = 1
    else:
        before += 1
    now = int(str(before) + str(before)[::-1])
    answer = (answer + now) % p
print(answer)

l=[]
i=0
s='1'
while i<100002:
    l.append(s+s[::-1])
    s=int(s)
    s+=1
    i+=1
    s=str(s)
n,m=map(int,input().split());
p=0
i=0 
while i<n:
    p=(p+int(l[i])%m)%m;
    i+=1
print(p)

k, p = [int(i) for i in input().split()]
ans = 0
for i in range(1,k+1):
    tmp = str(i)
    n = len(tmp)
    rev = tmp[::-1]
    ans += (i * 10**(n) + int(rev)) % p
print(ans % p)

k , p = map(int,input().split())

ans = 0 
for i in range(1,k+1):
  string = str(i) + str(i)[::-1]
  ans += int(string)
  ans %= p  
  
print(ans)

#k, p = 10, 10000

k, p = list(map(int,input().strip().split()))


res = 0

for i in range(1,k+1):

  x = str(i)

  x = x + x[::-1]


  res = (res+ int(x)) % p

print(res)


k, p = map(int, input().split())
ans = 0
for i in range(1, k + 1):
    ans += int(str(i) + str(i)[::-1])
    ans %= p
print(ans)