#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, p;
  long long sum = 0;
  string s, r;
  cin >> k >> p;
  for (int i = 1; i <= k; i++) {
    s = to_string(i);
    r = s;
    reverse(r.begin(), r.end());
    s += r;
    sum += stoll(s);
  }
  cout << sum % p << endl;
  return 0;
}
