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