#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
const long long mod = 1e9 + 7;
const long long INF = 10000000;
void flash() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(9);
}
long long bolt(long long n) {
  long long digit = 0;
  long long n1 = n;
  string s1;
  while (n1) {
    s1 += (n1 % 10) + '0';
    n1 /= 10;
    digit++;
  }
  long long num = 0;
  for (long long i = 0; i < s1.size(); i++) {
    num *= 10;
    num += s1[i] - '0';
  }
  long long x = 1;
  while (digit--) {
    x *= 10;
  }
  return n * x + num;
}
void solve();
int32_t main() {
  flash();
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long k, p;
  cin >> k >> p;
  long long sum = 0;
  for (long long i = 1; i <= k; i++) {
    sum += bolt(i);
    sum %= p;
  }
  cout << sum;
  return;
}
