#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int k, p;
  cin >> k >> p;
  long long temp, j;
  long long result = 0;
  for (int i = 1; i <= k; i++) {
    j = i;
    temp = i;
    while (j > 0) {
      temp = temp * 10 + j % 10;
      j /= 10;
    }
    result = (result % p + temp % p) % p;
  }
  result = result % p;
  cout << result << endl;
  return 0;
}
