#include <bits/stdc++.h>
using namespace std;
struct P {
  int x, y, z;
  bool operator<(const P &a) const {
    if (x != a.x) return x > a.x;
    return y < a.y;
  }
};
struct S {};
vector<P> v[20010];
int a, b, c, i, k, d, n, m, e[11111], dy[15] = {0, 0, -1, 1, -1, 1, -1, 1},
                                      dx[15] = {-1, 1, 0, 0, 1, 1, -1, -1};
int l[3006][111];
int o[13006];
long long x, y, z[4000];
double u[2000600];
int j[1210][111];
stack<int> s, s1;
queue<int> q;
deque<int> de;
map<long long, long long> p;
string r;
char r1[2222][2222];
bool as(double a, double b) { return a < b; }
int g(int a) {
  for (int x = a; x > 0; q.push(x % 10), x /= 10)
    ;
  int i = 0;
  for (; q.size(); q.pop()) i *= 10, i += q.front();
  return i;
}
long long f(int a) {
  long long i = a;
  for (int t = 1; t <= a; t *= 10, i *= 10)
    ;
  return i + g(a);
}
int main() {
  scanf("%d %d", &a, &b);
  for (int t = 1; t <= a; t++) {
    x += f(t);
    x %= b;
  }
  printf("%lld", x);
}
