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

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fo(i,n) for(int i=0;i<n;++i)
#define fn(i,n) for(int i=1;i<=n;++i)
#define Fo(i,k,n) for(int i=k;i<=n;++i)

typedef long long int lli;

int32_t main(){
    FIO
    lli n, m; cin >> n >> m;
    lli l = m * m;
    lli a = 10;
    lli b = 1;
    while(n > 0){
            if(n % 2 > 0) b *= a;
            b %= l;
            a = a * a;
            a %= l;
            n /= 2;
    }
    b /= m;
    cout << b % m << endl;
}

//Don't act like a loser.
//This code is written by huayucaiji
//You can only use the code for studying or finding mistakes
//Or,you'll be punished by Sakyamuni!!!
//#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
//#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
#include<bits/stdc++.h>
#define int long long
using namespace std;

int read() {
	char ch=getchar();
	int f=1,x=0;
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}

int n,m;

int qpow(int x,int y) {
	int ret=1;
	while(y) {
		if(y&1) {
			ret=ret*x%(m*m);
		}
		x=x*x%(m*m);
		y>>=1;
	}
	return ret;
}

signed main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	cin>>n>>m;
	cout<<qpow(10,n)/m<<endl;

	//fclose(stdin);
	//fclose(stdout);
	return 0;
}
