#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, k;
  cin >> n >> k;
  int i;
  long long int ans = 0;
  for (i = 1; i <= n; i++) {
    int c = i;
    int a = 0;
    while (c > 0) {
      a++;
      c = c / 10;
    }
    int j;
    long long int res = 1;
    for (j = 1; j <= a; j++) {
      res = res * 10;
    }
    long long int b = res;
    res = res * i;
    int tem = i;
    long long int sum = 0;
    while (tem > 0) {
      b = b / 10;
      sum += (tem % 10) * b;
      tem = tem / 10;
    }
    res = res + sum;
    res = res % k;
    ans = ans + res;
    ans = ans % k;
  }
  cout << ans;
  return 0;
}
