#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, p;
  scanf("%lld%lld", &k, &p);
  long long ans = 0;
  for (long long i = 1; i <= k; i++) {
    long long a = i, b = i;
    while (b != 0) {
      a = a * 10 + b % 10;
      b = b / 10;
    }
    ans = (ans + a) % p;
  }
  printf("%lld\n", ans);
}
