#include <bits/stdc++.h>
using namespace std;
int P;
int add(int a, int b) {
  if ((a += b) >= P) a -= P;
  return a;
}
int mul(int a, int b) { return 1ll * a * b % P; }
int n;
int gao(int d) {
  int ret = d % P;
  while (d) {
    ret = add(mul(ret, 10), (d % 10) % P);
    d /= 10;
  }
  return ret;
}
void solve() {
  int ans = 0;
  for (int i = (1); i < (n + 1); ++i) ans = add(ans, gao(i));
  printf("%d\n", ans);
}
int main() {
  while (~scanf("%d%d", &n, &P)) solve();
  return 0;
}
