#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, p;
  string s, srev, val;
  cin >> k >> p;
  long long num, ans = 0;
  for (int i = 1; i <= k; i++) {
    s = to_string(i);
    srev = s;
    reverse(s.begin(), s.end());
    val = srev + s;
    num = 0;
    for (int j = 0; j < val.length(); j++) {
      num = (val[j] - 48) + num * 10;
    }
    ans = ans + num;
  }
  cout << ans % p;
}
