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