#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k = 1000000009, r, l = 0, ans = 0, t, a[1000005],
                   b[100005] = {0}, m, h;
char x, y;
string second;
double p1, p2;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long rev(long long x) {
  long long pp = 0;
  while (x > 0) {
    pp = pp * 10 + (x % 10);
    x /= 10;
  }
  return pp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    long long p = floor(log10(i));
    p++;
    ans += (i * power(10, p, k)) + rev(i);
    ans %= k;
  }
  cout << ans << endl;
}
