#include <bits/stdc++.h>
using namespace std;
long long n, t, dig;
long long a[100010], ans;
long long f(long long x) {
  long long s = 0;
  dig = 1;
  while (x) {
    s = s * 10 + x % 10;
    x /= 10;
    dig *= 10;
  }
  return s;
}
void init() {
  for (long long i = 1; i <= n; i++) {
    long long qq = f(i);
    a[i] = i * dig + qq;
    ans = (ans + a[i]) % t;
  }
}
int main() {
  cin >> n >> t;
  init();
  cout << ans << endl;
  return 0;
}
