#include <bits/stdc++.h>
using namespace std;
long long get(int x) {
  string s;
  while (x) {
    s += char(x % 10 + '0');
    x /= 10;
  }
  string t = s;
  reverse(s.begin(), s.end());
  s.append(t);
  return atoll(s.c_str());
}
int main() {
  int k, p;
  cin >> k >> p;
  int res = 0;
  for (int i = 1; i <= k; i++) res = (get(i) + res) % p;
  cout << res;
  return 0;
}
