#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll n, k, y, count;
  while (cin >> n >> k) {
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
      y = i;
      count = i;
      while (y) {
        count = count * 10 + y % 10;
        y /= 10;
      }
      sum = sum + (count % k);
      sum %= k;
    }
    cout << sum << endl;
  }
  return 0;
}
