#include <bits/stdc++.h>
using namespace std;
long long k, t, d;
long long a[100005], ans;
long long fin(long long x) {
  long long s = 0;
  d = 1;
  while (x) {
    s = s * 10 + x % 10;
    x /= 10;
    d *= 10;
  }
  return s;
}
void cl() {
  for (int i = 1; i <= k; i++) {
    long long qq = fin(i);
    a[i] = i * d + qq;
    ans = (ans + a[i]) % t;
  }
}
int main() {
  scanf("%lld %lld", &k, &t);
  cl();
  printf("%lld\n", ans % t);
  return 0;
}
