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