#include <bits/stdc++.h>
using namespace std;
long long p, k, i, tmp, val, res;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (cin >> k >> p, i = 1; i <= k; ++i) {
    tmp = i;
    val = i;
    do val = val * 10 + tmp % 10, tmp /= 10;
    while (tmp);
    res = (res + val) % p;
  }
  cout << res << endl;
  return 0;
}
