#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll x = mod_pow(10ll, n, m*m);
    cout << x / m << endl;
}

#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class L, class R> 
ostream& operator<<(ostream &os, const pair<L,R> &input) {
    os << "(";
	os << input.first << "," << input.second;
	return os << ")";
}

template<class T> 
ostream& operator<<(ostream &os, const vector<T> &input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, const set<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const unordered_set<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const multiset<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, const unordered_multiset<T> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, const map<L,R> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << " , " << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, const unordered_map<L,R> &input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << " , " << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 500005;
const int INF = 1e9;
const int MOD = 998244353;

class TaskA {
private:
	int mod;
	int mul(int a, int b) {
		return (ll) a * b % mod;
	}
	int fastMod(int base, ll pot) {
		int ans = 1;
		while (pot) {
			if (pot & 1) {
				ans = mul(ans, base);
			}
			base = mul(base, base);
			pot/=2;
		}
		return ans;
	}

public:
	void solveOne(int it){
		ll n, m;
		cin >> n >> m;
		mod = m * m;
		int ans = fastMod(10, n);
		cout << (ans / m) % m << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}
