#include <bits/stdc++.h>
using namespace std;
long long a[100005];
char s[1000];
int main() {
  int k = 1;
  int cnt = 0;
  while (cnt <= 100000 + 5) {
    sprintf(s, "%d", k);
    k++;
    int len = strlen(s);
    long long b;
    for (int i = 0; i < len; i++) {
      s[len + i] = s[len - i - 1];
    }
    s[len * 2] = '\0';
    sscanf(s, "%I64d", &b);
    a[cnt++] = b;
  }
  int p;
  cin >> k >> p;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    sum = (sum + a[i]) % p;
  }
  cout << sum;
  return 0;
}
