#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 1000 * 1000 + 47;
long long getN(long long a) {
  long long res = a;
  while (a) {
    res = res * 10 + a % 10;
    a /= 10;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, p;
  cin >> k >> p;
  long long res = 0;
  for (int i = (1); i < (k + 1); i++) {
    res = (res + getN(i)) % p;
  }
  cout << res << endl;
}
