#include <bits/stdc++.h>
using namespace std;
long long k, p, ans, P[100005];
long long fun(long long x) {
  string s = to_string(x);
  string t = s;
  reverse((t).begin(), (t).end());
  long long l = (long long)s.size();
  long long res = x * P[l] % p;
  res = (res + stoll(t) % p) % p;
  return res;
}
void solve() {
  cin >> k >> p;
  P[0] = 1;
  for (__typeof((100005)) i = (1); i < (100005); i++)
    P[i] = (P[i - 1] * 10) % p;
  for (__typeof((k + 1)) i = (1); i < (k + 1); i++) ans = (ans + fun(i)) % p;
  {
    cout << ans << "\n";
    return;
  };
}
void prep() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  prep();
  cout << fixed << setprecision(12);
  while (t--) solve();
  return 0;
}
