#include <bits/stdc++.h>
long long ans, p;
long long ten[]{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};
int len(int num) {
  int x = 0;
  while (ten[x] <= num) x++;
  return x;
}
long long deal(int num) {
  int l = len(num);
  long long rtn = num * ten[l];
  for (int i = 0; i < l; i++) {
    int j = l - i;
    long long x = num % ten[j];
    while (--j) x /= 10;
    rtn += x * ten[i];
  }
  return rtn;
}
int main() {
  int n;
  scanf("%d%lld", &n, &p);
  for (int i = 1; i <= n; i++) ans = (ans + deal(i)) % p;
  printf("%lld", ans);
}
