#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	const ll mod = m * m;
	ll x = 10, y = n, z = 1;
	while(y > 0){
		if(y & 1){ z = (z * x) % mod; }
		x = (x * x) % mod;
		y >>= 1;
	}
	cout << z / m << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
#define pi M_PI
typedef pair<ll, ll> llPair;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef priority_queue<ll> pqll;
ll MOD = 1000000007;
/*
Really doe, like really doe
Really doe, like really doe
*/
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y / 2, m) % m;
    p = (p * p) % m;

    return (y % 2 == 0) ? p : (x * p) % m;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    t = 1;
    for (ll z = 0; z < t; ++z)
    {
        ll n, m;
        cin >> n >>      m;
        n = power(10, n, m * m);
        cout << (n / m) % m << '\n';
    }


    return 0;
}
