#include <bits/stdc++.h>
using namespace std;
int k, MOD;
int pal(int i) {
  long long rez = i;
  while (i > 0) {
    rez = rez * 10 + i % 10;
    if (rez >= MOD) rez %= MOD;
    i /= 10;
  }
  return (int)rez;
}
int main() {
  cin >> k >> MOD;
  int sum = 0;
  for (int i = 1; i <= k; i++) {
    sum += pal(i);
    if (sum >= MOD) sum -= MOD;
  }
  cout << sum << "\n";
  return 0;
}
