#include <bits/stdc++.h>
using namespace std;
long long int sum(long long int k, long long int p) {
  long long int sum = 0;
  stringstream st;
  for (int i = 1; i <= k; i++) {
    stringstream st;
    st << i;
    string num = st.str();
    string revNum = num;
    reverse(revNum.begin(), revNum.end());
    string strnum = (num + revNum);
    stringstream geek(strnum);
    long long int number = 0;
    geek >> number;
    sum = (sum % p + number % p) % p;
  }
  return sum;
}
int main() {
  long long int k, p;
  cin >> k >> p;
  long long int ans = sum(k, p);
  ans = ans % p;
  cout << ans;
  return 0;
}
