#include <bits/stdc++.h>
using namespace std;
const long long mul = 1e9 + 7;
const int maxn = 1e6 + 1;
long long k, p, dem = 0, kq = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> k >> p;
  for (int i = 1; i <= k; ++i) {
    long long j = i;
    long long t = i;
    while (j > 0) {
      t = t * 10 + j % 10;
      j /= 10;
    }
    kq = (kq % p + t % p) % p;
  }
  kq = kq % p;
  cout << kq;
}
