#include <bits/stdc++.h>
using namespace std;
long long n, m, sum;
long long check(long long n) {
  long long ans = n, t = n;
  while (t) {
    ans = ans * 10 + t % 10;
    t /= 10;
  }
  return ans;
}
int main() {
  scanf("%I64d %I64d", &n, &m);
  for (int i = 1; i <= n; i++) {
    sum += check(i);
  }
  printf("%I64d\n", sum % m);
}
