#include <bits/stdc++.h>
long long k, p, ans;
long long getk(long long v) {
  long long ret = 0, bit = 1;
  for (long long i = v; i > 0; i /= 10, bit *= 10) ret = ret * 10 + i % 10;
  ret += v * bit;
  return ret;
}
int main(void) {
  scanf("%I64d%I64d", &k, &p);
  for (long long i = 1; i <= k; i++) ans = (ans % p + getk(i)) % p;
  printf("%I64d\n", ans);
  return 0;
}
