#include <bits/stdc++.h>
using namespace std;
long long length(long long a) {
  long long cnt = 1;
  while (a /= 10)
    if (a != 0) cnt++;
  return cnt;
}
long long proc(long long a) {
  long long tmp = 0;
  long long len = length(a);
  tmp = a * pow(10, len);
  for (long long i = 1; i <= len; i++) {
    long long b = a % 10;
    tmp += (b * pow(10, len - i));
    a /= 10;
  }
  return tmp;
}
int main() {
  long long k, p;
  cin >> k >> p;
  long long tmp = 0, sum = 0;
  do {
    tmp++;
    sum += proc(tmp);
  } while (tmp != k);
  cout << sum % p;
}
