#include <bits/stdc++.h>
using namespace std;
long long k, p, sum = 0, d, c, nods;
int main() {
  cin >> k >> p;
  for (int i = 1; i <= k; ++i) {
    d = i;
    c = i;
    while (c > 0) {
      d *= 10;
      d += c % 10;
      c /= 10;
    }
    sum = (sum + d) % p;
  }
  cout << sum;
  return 0;
}
