#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e6 + 7);
const long long BASE = (int)(20122007);
int k;
long long p;
long long rev(long long u) {
  long long res = 0;
  while (u) {
    res = res * 10 + u % 10;
    u /= 10;
  }
  return res;
}
long long getNum(int x) {
  long long sX = x * 1LL;
  long long revX = rev(x * 1LL);
  int len = 0;
  while (x) {
    ++len;
    x /= 10;
  }
  for (int i = 1; i <= len; ++i) sX = sX * 10;
  sX = sX + revX;
  return sX;
}
int main() {
  while (cin >> k >> p) {
    long long sum = 0;
    for (int i = 1; i <= k; ++i) {
      long long nums = getNum(i);
      sum = (sum + nums) % p;
    }
    cout << sum << endl;
  }
  return 0;
}
