#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  long long p;
  cin >> k >> p;
  long long ans = 0;
  for (int i = 1; i <= k; i++) {
    string s = to_string(i);
    string ss = s;
    reverse(ss.begin(), ss.end());
    ans = (ans + stoll(s + ss)) % p;
  }
  cout << ans << endl;
}
