#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int long long
#define pow abcdef_pow
#define sqr(x) ((x)*(x))

int pow(int a, int b, int mod) {
  if (b == 0) return 1;
  int t = pow(a, b / 2, mod);
  t = (t * t) % mod;
  if (b % 2) return (t * a) % mod;
  return t;
}

signed main() {
  // freopen("in" , "r", stdin );
  cin.tie(0)->sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int ans = ((pow(10, n, sqr(m)) - pow(10, n, m) + sqr(m) * sqr(m)) % sqr(m)) / m;
  cout << ans << endl;
}

#include <bits/stdc++.h>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <typename T>
void read(T &);
template <typename T>
void write(const T &);

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;

ll pow(ll a, ll b, ll m);

int main() {
  ll n, m;
  read(n), read(m);
  write(pow(10, n, m * m) / m % m), EL;
  return 0;
}

ll pow(ll a, ll b, ll m) {
  ll ans = 1, now = a;
  while (b) {
    if (b & 1) {
      ans = ans * now % m;
    }
    now = now * now % m;
    b >>= 1;
  }
  return ans;
}

template <typename T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <typename T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}
