#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using LL = uint64_t;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a,b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100
#define MAX6 1001001
#define MAX7 10010010
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define MAX_LL LLONG_MAX
#define CLR(mat) memset(mat, 0, sizeof(mat))
template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }
#define MOD 1000000007
//const ll inf=1e18;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back


inline void chadd(ll &a, ll b){a+=b;if(a>=MOD)a-=MOD;}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}

int main(){
   ll N,M;cin>>N>>M;
   cout << mod_pow(10, N, M * M) / M % M << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;

inline ll fpow(reg ll x,reg ll exp,reg ll mod){
	reg ll res=1;
	x%=mod;
	while(exp){
		if(exp&1)
			res=res*x%mod;
		x=x*x%mod;
		exp>>=1;
	}
	return res;
}

ll n;
int m;

int main(void){
	scanf("%lld%d",&n,&m);
	printf("%lld\n",fpow(10,n,m*m)/m);
	return 0;
}