#include <bits/stdc++.h>
using namespace std;
int k, p;
int ten[20];
int a[20];
int main() {
  scanf("%d%d", &k, &p);
  int num = 0;
  ten[0] = 1;
  for (int i = 1; i <= 6; ++i) ten[i] = ten[i - 1] * 10 % p;
  int ans = 0;
  while (num < k) {
    ++num;
    int l = 0, n = num;
    while (n) a[++l] = n % 10, n /= 10;
    ans = (ans + (long long)num * ten[l]) % p;
    for (int i = 1; i <= l; ++i) ans = (ans + a[i] * ten[l - i]) % p;
  }
  printf("%d\n", ans);
  return 0;
}
