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

long long n;
int m;

long long add(long long a, long long b, long long mod){
	return (a + b) % mod;
}

long long mul(long long a, long long b, long long mod){
	long long r = 0;
	while(b > 0){
		if(b & 1) r = add(r, a, mod);
		a = add(a, a, mod);
		b >>= 1;
	}
	return r;
}

long long pow_mod(long long a, long long b, long long mod){
	long long r = 1 % mod;
	while(b > 0){
		if(b & 1) r = mul(a, r, mod);
		a = mul(a, a, mod);
		b >>= 1;
	}
	return r;
}

int main(){
	cin >> n >> m;
	long long R = pow_mod(10, n, 1LL * m * m);
	long long r = R % m;
	printf("%lld\n", (R - r) / m);
	return 0;
}

#include <iostream>
using namespace std;
 
typedef long long ll;
 
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)<(y)?(y):(x))
 
ll comb(ll n, ll k){
    if (k == 0 || k == n) return 1;
    if (k == 1 || k == n-1) return n;
    return comb(n-1,k)+comb(n-1,k-1);
}
 
int main(){
    ll n,k;cin >> n >> k;--k;
    for(ll xyz=3;xyz<=3*n;++xyz){
        if(xyz <= n+1){
            ll xmax = xyz-2;
            ll s = (2*xyz-3-xmax)*xmax/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=1;x<=xmax;++x){
                ll c = xyz-1-x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=1+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }else if(xyz < 2*n+1){
            ll xmax = xyz-n-1;
            ll s = (4*n-2*xyz+xmax+3)*xmax/2;
            if(s <= k){
                k -= s;
            }else{
                for(ll x=1;x<=xmax;++x){
                    ll c = 2*n-xyz+1+x;
                    if(c <= k){
                        k -= c;
                        continue;
                    }
                    ll y=xyz-n-x+k;
                    cout << x << " " << y << " " << (xyz-x-y) << "\n";
                    return 0;
                }
            }
            ll xmin = xyz-n;
            s = (2*xyz-2-n-xmin)*(n-xmin+1)/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=xmin;x<=n;++x){
                ll c = xyz-1-x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=1+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }else{
            ll s = (3*n-xyz+2)*(3*n-xyz+1)/2;
            if(s <= k){
                k -= s;
                continue;
            }
            for(ll x=xyz-2*n;x<=n;++x){
                ll c = 2*n-xyz+1+x;
                if(c <= k){
                    k -= c;
                    continue;
                }
                ll y=xyz-n-x+k;
                cout << x << " " << y << " " << (xyz-x-y) << "\n";
                return 0;
            }
        }
    }
    return 0;
}
