#include <bits/stdc++.h>
using namespace std;
long long p;
long long trans(long long a) {
  long long ans = a;
  while (a) {
    ans = (ans * 10 + a % 10) % p;
    a /= 10;
  }
  return ans;
}
int main() {
  int k;
  scanf("%d", &k);
  cin >> p;
  long long sum = 0;
  for (long long i = 1; i <= k; i++) {
    sum = (sum + trans(i)) % p;
  }
  cout << sum << endl;
  return 0;
}
