#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
long long k, p;
int main() {
  ios::sync_with_stdio(false);
  cin >> k >> p;
  long long now = 1;
  long long sum = 0, ans = 0;
  for (int i = 1; i <= k; i++) {
    now = i;
    long long f = now, mid = 0, q = now;
    while (f) {
      mid = mid * 10 + (f % 10);
      f /= 10;
      q *= 10;
    }
    ans += q + mid;
    ans %= p;
  }
  cout << ans;
  return 0;
}
