#include <bits/stdc++.h>
int main() {
  int k, p;
  std::cin >> k >> p;
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    int cur = i;
    int cc = cur;
    std::stack<int> s;
    std::queue<int> q;
    while (cc > 0) {
      q.push(cc % 10);
      s.push(cc % 10);
      cc /= 10;
    }
    unsigned long long num = 0;
    while (!s.empty()) {
      num = num * 10 + s.top();
      s.pop();
    }
    while (!q.empty()) {
      num = num * 10 + q.front();
      q.pop();
    }
    ans = (ans + num) % p;
  }
  std::cout << ans << "\n";
}
