#include <bits/stdc++.h>
int mod = 1000000007;
const double pi = 3.141592653689793238460;
const int inf = 0x3f3f3f3f;
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void r(int arr[], int d, int n) {
  d = d % n;
  int g_c_d = gcd(d, n);
  for (int i = 0; i < g_c_d; i++) {
    int temp = arr[i];
    int j = i;
    while (1) {
      int k = j + d;
      if (k >= n) k = k - n;
      if (k == i) break;
      arr[j] = arr[k];
      j = k;
    }
    arr[j] = temp;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long k, p;
  cin >> k >> p;
  long long sum = 0;
  for (int i = 0; i < k + 1; i++) {
    string s = to_string(i);
    string x = to_string(i);
    reverse(x.begin(), x.end());
    s += x;
    long long m = stoll(s);
    sum = (sum + m) % p;
  }
  cout << sum % p << endl;
}
