#include <bits/stdc++.h>
using namespace std;
long long findpal(long long n) {
  long long m = n, m1 = 0, ctr = 0, rem;
  while (n != 0) {
    rem = n % 10;
    m1 = m1 * 10 + rem;
    ctr++;
    n /= 10;
  }
  m = m * pow(10, ctr) + m1;
  return m;
}
int main() {
  long long k, p, i, rev, sum = 0;
  cin >> k >> p;
  i = 0;
  while (k--) {
    i++;
    rev = findpal(i);
    sum += rev;
    sum %= p;
  }
  cout << sum;
  return 0;
}
