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