#include <bits/stdc++.h>
int main() {
  long long sum = 0, N, p;
  scanf("%lld%lld", &N, &p);
  for (long long i = 1; i <= N; i++) {
    long long temp = i, k = i;
    while (k) {
      temp = temp * 10 + k % 10;
      k /= 10;
    }
    sum = (temp + sum) % p;
  }
  printf("%lld\n", sum % p);
  return 0;
}
