#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
//first second
//memset(dp, -1, sizeof dp);
//string binary =bitset<8>(n).to_string();
//(mod)->(10*mod+currentmodulo)%m
struct keycompare {
    bool operator()(const pair<ll, ll>& v, const ll& k) {
        return (v.first < k);
    }
    bool operator()(const ll& k, const pair<ll, ll>& v) {
        return (k < v.first);
    }
};

ll mod1=998244353,mod2=1000000007,limit=9223372036854775807;
long double pi=3.1415926535897932;
ll modpow(ll x, ll n, ll m) {

    if(x>m){
        x%=m;
    }
    if (n == 0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
ll gcd(ll a, ll b)
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  

}
bool isprime(ll n){
    if(n==2)
        return true;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

ll power(ll x,ll n){
    if(n<0){
        return 0;
    }
    ll x_n=1;
    for(ll i=0;i<n;i++){
        x_n*=x;
    }
    return x_n;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m; cin>>n>>m;
    ll k=modpow(10,n,m);
    ll mm=m*m;
    for(int i=0;i<m;i++){
        ll temp=modpow(10,n,mm)-k%mm-(m*i)%mm;
        temp=temp%mm;
        if(temp==0){
            cout<<i<<endl; return 0;
        }
    }
}
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define LL long long

using namespace std;
const int N = 55;

int t;
LL n, m;

LL qp(LL a, LL b)
{
    LL res = 1;
    while (b)
    {
        if (b & 1) res = res * a % (m * m);
        b >>= 1;
        a = a * a % (m * m);
    }
    return res;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    LL res = qp(10, n);
    printf("%lld\n", res / m);
    return 0;
}
