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

// (b ^ p) % mod
long long modpow(long long b, long long p, long long mod) {
    long long res = 1;
    while (p > 0) {
        if (p & 1) {
            res = res * b % mod;
        }
        b = b * b % mod;
        p >>= 1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N, M;
    cin >> N >> M;
    long long R = modpow(10, N, M * M);
    cout << R / M << '\n';
    return 0;
}
#pragma GCC optimize ("trapv")
#include <bits/stdc++.h>
#include<algorithm>
#include <vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
int ar[106]={0};
ll moduloPower(ll base, ll power, ll modulo)
{
  ll res=1;
  while(power)
  {
    if(power & 1)
    {
      res*=base;
      res%=modulo;
    }
    base*=base;
    base%=modulo;
    power>>=1;
  }
  return res;
}
ll por(ll n)
{
  return ceil(log2(n))==floor(sqrt(n));
}
void solve()
{
  ll n, a,m=0,b=0, c=0,k=0, i, j, l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  cout<<(moduloPower(10,n,a*a))/a;
  
}
int main()
{
  ll i, j, b=0, c=1,yog=0,hit=1;
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
//cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}