#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long powerm(long long a, long long n, long long m)
{
    if (n==1) return a%m;
    if (n==0) return 1;
    if (n%2) return (a*powerm((a*a)%m,n/2,m))%m;
    return powerm((a*a)%m,n/2,m);
}


void amain()
{
    long long n; cin >> n;
    long long m; cin >> m;
    long long x;
    x=powerm(10,n,m*m);
    //cout << x << endl;
    cout << x/m << endl;
    return;
}

int main()
{
    amain();
    return 0;
}

// Artur Kraska, II UWr

#include <bits/stdc++.h>

#define forr(i, n)                  for(int i=0; i<n; i++)
#define FOREACH(iter, coll)         for(auto iter = coll.begin(); iter != coll.end(); ++iter)
#define FOREACHR(iter, coll)        for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define testy()                     int _tests; scanf("%d", &_tests); FOR(_test, 1, _tests)
#define CLEAR(tab)                  memset(tab, 0, sizeof(tab))
#define CONTAIN(el, coll)           (coll.find(el) != coll.end())
#define FOR(i, a, b)                for(int i=a; i<=b; i++)
#define FORD(i, a, b)               for(int i=a; i>=b; i--)
#define MP                          make_pair
#define PB                          push_back
#define ff                          first
#define ss                          second
#define deb(X)                      X;

#define M 1000000007
#define INF 1000000007LL

using namespace std;

long long n, m, a;

long long pow(long long a, long long n, long long m)
{
    if(n == 0)
        return 1 % m;
    long long p = pow(a, n/2, m);
    p = p*p%m;
    if(n & 1)
        p = p*a%m;
    return p;
}

int main()
{
    scanf("%lld %lld", &n, &m);
    long long p = pow(10, n, m*m);
    p /= m;
    cout << p%m << endl;

    return 0;
}
