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