#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <random>
#include <chrono>
#include <queue>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <limits>

#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define showv(v) for(int i : v) cout << i << ' '; cout << '\n';
#define show(begin, end) for(auto it = begin; it != end; it++) cout << *it << ' '; cout << '\n';
#define MAXN 300005

using namespace std;
using namespace std::chrono;
typedef long long   ll;
typedef long double ld;

int inf = 1e9 + 9;
int mod = 1e9 + 7;

vector<ll> sieve(ll n) {
    vector<bool> prime(n, true);
    prime[0] = prime[1] = false;
    for(int i = 2;i < n;i++)
        if(prime[i])
            for(int j = 2 * i;j < n;j += i)
                prime[j] = false;

    vector<ll> primes;
    for(ll i = 0;i < n;i++)
        if(prime[i]) primes.push_back(i);
    return primes;
}

ll bpow(ll a, ll n, ll m) {
    if(n == 0)
        return 1;
    if(n & 1) {
        ll res = bpow(a, n - 1, m);
        res = (res * a) % m;
        return res;
    } else {
        ll res = bpow(a, n / 2, m);
        res = (res * res) % m;
        return res;
    }
}

void solve() {
    ll n, m; cin >> n >> m;
    ll mm = m * m;
    // (10 ^ n) % m = a
    // 10 ^ n = p * m * m + b * m + a
    // (10 ^ n( % mm =
    ll a = bpow(10, n, m);
    ll c = bpow(10, n, mm);
    ll b = (c - a) / m;
    cout << b << endl;
}

int main() {
    faster
    auto start = high_resolution_clock::now();
    int test; test = 1;
    while(test--) {
        solve();
    }
    auto stop = high_resolution_clock::now();
    double duration = duration_cast<milliseconds>( stop - start ).count() * 1.0;
    // cout << "Time taken by function: " << duration << " ms " << endl;
    return 0;
}

#include "iostream"
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>

using namespace:: std;

long long int pow (long long int n, long int k, long int m)
    {

    if (k == 1)
        return n;

    else if (k % 2 == 0)
        return ((pow (n, k / 2, m) % m * pow (n, k / 2, m) % m) % m);
    else
        return ((pow (n, k - 1, m) % m * (n % m)) % m);
    }


int main()
    {

    long long int n, m;
    cin>>n>>m;

    cout<<(pow (10, n, m * m) / m) % m;

    return 0;
    }
