#include <bits/stdc++.h>
using namespace std;
void mul(long long x, long long &y) {
  while (x) {
    y *= 10;
    x /= 10;
  }
}
long long reverse(long long x) {
  long long res = 0;
  while (x) {
    res *= 10;
    res += x % 10;
    x /= 10;
  }
  return res;
}
int main() {
  long long k, p;
  cin >> k >> p;
  long long res = 0;
  for (long long i = 1; i <= k; i++) {
    long long now = i;
    long long rev = reverse(i);
    mul(i, now);
    now += rev;
    res = (res + now) % p;
  }
  cout << res << endl;
  return 0;
}
