#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
inline int add(int a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline int mul(int a, int b) { return (a * 1ll * b) % 1000000007; }
inline int power(int a, int b) {
  int rt = 1;
  while (b > 0) {
    if (b & 1) rt = mul(rt, a);
    a = mul(a, a);
    b >>= 1;
  }
  return rt;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    long long int k, p;
    cin >> k >> p;
    long long int sum = 0;
    for (int i = 1; i <= k; i++) {
      string s = to_string(i);
      string temp = s;
      reverse(temp.begin(), temp.end());
      s += temp;
      reverse(s.begin(), s.end());
      int n = s.length();
      for (int j = 0; j < n; j++) {
        sum = (sum % p + (s[j] - '0') * (long long int)pow(10, j) % p) % p;
      }
    }
    cout << sum << "\n";
  }
  return 0;
}
