#include <bits/stdc++.h>
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return ((x / gcd(x, y) * y)); }
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool prime(long long n) {
  if (n == 2)
    return 1;
  else if (n < 2 || !(n & 1))
    return 0;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int main() {
  fast();
  long long k, p, x, y, ans = 0;
  cin >> k >> p;
  for (int i = 1; i <= k; i++) {
    x = i;
    y = i;
    while (y) {
      x = x * 10 + y % 10;
      y /= 10;
    }
    ans += (x % p);
  }
  ans %= p;
  cout << ans;
  return 0;
}
