#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
template <typename T>
std::string to_string(const T& n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}
int genzcy(int i, int p) {
  string s = to_string(i);
  string t = "";
  for (int j = 0; j < (s.size()); j++) {
    t = s[s.size() - j - 1] + t;
    t = t + s[s.size() - j - 1];
  }
  return stoll(t) % p;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, p;
  cin >> k >> p;
  long long ans = 0;
  for (int i = 0; i < (k); i++) ans = (ans + genzcy(i + 1, p)) % p;
  cout << ans << "\n";
  return 0;
}
