#include <bits/stdc++.h>
using namespace std;
long long zcy(long long x) {
  long long y = x;
  while (y != 0) {
    x = (x * 10) + (y % 10);
    y /= 10;
  }
  return x;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) ans = (ans + zcy(i)) % k;
  cout << ans;
  return 0;
}
