#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toStr(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
inline long long toLL(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
int main() {
  long long k, p;
  cin >> k >> p;
  long long ans = 0;
  for (int i = (1); i <= (k); ++i) {
    string s1 = toStr(i);
    string s2 = toStr(i);
    reverse((s2).begin(), (s2).end());
    long long num = toLL(s1 + s2);
    ans += num;
  }
  cout << (ans % p) << endl;
  return 0;
}
