#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long k, p, num, num1;
  cin >> k >> p;
  long long sum = 0;
  if (k > 0)
    for (int i = 1; i <= k; i++) {
      num1 = i;
      num = i;
      while (num1 > 0) {
        num *= 10;
        num += (num1 % 10);
        num1 /= 10;
      }
      sum = sum + num;
    }
  sum = sum % p;
  cout << sum;
  return 0;
}
