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

# -*- coding:utf-8 -*-
# #NYAN NYAN
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
#░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░
#░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░
#░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░
#░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░
#░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░
#░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░
#░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░
#░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░
#░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░
#░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░
#░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░
#░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
from __future__ import print_function
import os
import sys
ReadTarget = None
WriteTarget = None

def AddImports(libraryNames):
    for libname in libraryNames:
        if (type(libname) == type(tuple())):
            short = libname[1]
            libname = libname[0]
        else:
            short = None
        try:
            lib = __import__(libname)
        except ImportError:
            pass
        else:
            if short:
                globals()[short] = lib
            else:
                globals()[libname] = lib
    return True
libnames = ['fileinput', 'codecs', 'operator', 'functools', 'math', 'io', 'platform', 'collections', 'mmap', 'logging', 'logging.handlers']
AddImports(libnames)
IntellisenseHint = False
if IntellisenseHint:
    import fileinput
    import codecs
    import operator
    import functools
    import math
    import io
    import platform
    import collections
    import mmap
    import logging
    import logging.handlers
    import defs

def readSequence(elementType=None, inputLine=None, seperator=None, strip=True):
    global readTarget
    if (inputLine == None):
        inputLine = readTarget.readline()
    if strip:
        inputLine = inputLine.strip()
    if isinstance(inputLine, bytes):
        inputLine = inputLine.decode('utf-8')
    if (elementType == None):
        return [x for x in inputLine.split(seperator)]
    return [elementType(x) for x in inputLine.split(seperator)]
rl = RobertsSpaceIndustries = readSequence

def ToSpaceSeperatedString(targetList):
    return ' '.join(map(str, targetList))

def convert_to_bytes(arg):
    if isinstance(arg, bytes):
        return arg
    elif isinstance(arg, str):
        return arg.encode('utf-8')
    elif hasattr(arg, '__iter__'):
        return ' '.join(map(convert_to_bytes, arg))
    else:
        return str(arg).encode('utf-8')

class edx_in:

    def __init__(self, target=None):
        self.target = target

    def create_lineTokenizer(self):
        if self.mm:
            for line in iter(self.mm.readline, ''):
                (yield line)
        else:
            for line in iter(self.stream.readline, ''):
                (yield line)

    def __enter__(self):
        if (self.target and UseFileIO):
            self.isFileEmpty = (os.stat(self.target).st_size == 0)
            if self.isFileEmpty:
                return self
            self.stream = open(self.target, 'rb', 1)
            self.mm = mmap.mmap(self.stream.fileno(), 0, access=mmap.ACCESS_READ)
        else:
            self.mm = None
            self.isFileEmpty = True
            self.stream = sys.stdin
        self.lines = self.create_lineTokenizer()
        self.lineTokens = None
        return self

    def __exit__(self, type, value, traceback):
        if (not self.isFileEmpty):
            if self.mm:
                self.mm.close()
            self.stream.close()

    def next_line(self):
        ret = None
        try:
            ret = ' '.join(self.lineTokens)
            self.lineTokens.close()
            if (ret == ''):
                raise ValueError()
            return ret
        except:
            pass
        if hasattr(self.lines, 'next'):
            ret = self.lines.next()
        if hasattr(self.lines, '__next__'):
            ret = self.lines.__next__()
        return ret

    def next_int(self):
        return int(self.next_token())

    def next_float(self):
        return float(self.next_token())

    def next_str(self, encoding=None):
        if encoding:
            return self.next_token().decode(encoding)
        else:
            return self.next_token()

    def getLineTokens(self, line):
        for token in iter(line.split()):
            (yield token)

    def nextNToken(self, rep=0):
        ans = []
        while (rep > 0):
            ans.append(self.next_token())
            rep -= 1
        return ans

    def next_token(self):
        try:
            if hasattr(self.lineTokens, 'next'):
                ret = self.lineTokens.next()
            if hasattr(self.lineTokens, '__next__'):
                ret = self.lineTokens.__next__()
            return ret
        except:
            self.lineTokens = self.getLineTokens(self.next_line())
            return self.next_token()

class edx_out:

    def __init__(self, target=None):
        self.target = target

    def __enter__(self):
        self.is_cpython = (platform.python_implementation() == 'CPython')
        if (self.target and UseFileIO):
            if self.is_cpython:
                self.stream = open(self.target, 'wb', 1)
            else:
                self.stream = io.BytesIO()
        else:
            self.stream = sys.stdout
        return self

    def __exit__(self, type, value, traceback):
        if (self.target and UseFileIO):
            if self.is_cpython:
                self.stream.close()
            else:
                outf = open(self.target, 'wb', 1)
                outf.write(self.stream.getvalue())
                outf.close()
                self.stream.close()
        else:
            pass

    def write(self, arg):
        self.stream.write(convert_to_bytes(arg))

    def writeln(self, arg):
        self.write(arg)
        self.write('\n')

    def test(this, expression):
        frame = sys._getframe(1)
        exp = expression
        ans = repr(eval(exp, frame.f_globals, frame.f_locals))
        this.debug(((('test : ' + exp) + ' = ') + ans))
        pass

def solve():
    solve897b()

def solve897b():
    (k, p) = (ri(), ri())
    leadpick = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    midpick = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    li = []
    i = 1
    num = 1
    ans = 0
    while (i <= k):
        ans += int((str(num) + str(num)[::(-1)]))
        ans %= p
        i += 1
        num += 1
    ans %= p
    wl(ans)
reader = None
writer = None
try:
    logger1 = logging.getLogger('log1')
    debug = (lambda *x: logger1.log(logging.DEBUG, convert_to_bytes(x)))
    PutLevel = 100
    logging.PUT = PutLevel
    logging.addLevelName(PutLevel, 'PUT')
    logger1.setLevel(logging.PUT)
    formatter = logging.Formatter()
except:
    pass
with edx_in(ReadTarget) as Reader:
    with edx_out(WriteTarget) as Writer:
        try:
            outHandler = logging.StreamHandler(Writer.stream)
            outHandler.setFormatter(formatter)
            logger1.addHandler(outHandler)
            put = (lambda *args: logger1.log(logging.PUT, convert_to_bytes(args)))
            info = (lambda *args: logger1.log(logging.INFO, convert_to_bytes(args)))
            critical = (lambda *args: logger1.log(logging.CRITICAL, convert_to_bytes(args)))
        except:
            debug = Writer.writeln
            put = Writer.writeln
            info = Writer.writeln
            critical = Writer.writeln

        def nop(*arg):
            pass
        debug = nop
        test = nop
        info = nop
        reader = Reader
        writer = Writer
        ri = reader.next_int
        rs = reader.next_str
        rt = reader.next_token
        rf = reader.next_float
        rl = reader.next_line
        wl = writer.writeln
        solve()
