/*
ID:ACwisher
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
//const int N=;
typedef long long ll;
ll n;
int m; 
int power(int a,ll b,int mo){
	int ret=1;
	while(b){
		if(b&1) ret=1ll*ret*a%mo;
		a=1ll*a*a%mo; b>>=1;
	}
	return ret;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdiout);
	scanf("%lld%d",&n,&m);
	int mm=m*m;
	int k=power(10,n,mm);
	printf("%d\n",k/m);
	return 0;
}


/*########################################################################
# File Name: A.cpp
# Author: SoMnus_L
# Mail: lr599909928@gmail.com
# Created Time:日  1/10 14:45:58 2021
########################################################################*/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
#define rep(a,b,c) for(int a=b;a<=c;++a)
#define per(a,b,c) for(int a=b;a>=c;--a)
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}

ll n,m;

ll fpow(ll a,ll k,ll mod){
	ll res=1;
	while(k){
		if(k&1) res=res*a%mod;
		k>>=1;
		a=a*a%mod;
	}
	return res;
}


int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	cin>>n>>m;

	cout<<fpow(10,n,m*m)/m%m<<'\n';


    return 0;
}
