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

typedef long long ll;

ll n,m,mod;

ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    mod=m*m;
    cout<<qpow(10,n)/m<<endl;

    return 0;
}
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cassert>
#include <numeric>
typedef long long ll;
#define FOR(i, a, b) for(int i=(a); i<(b);i++)
#define REP(i, n) for(int i=0; i<(n);i++)
#define ROF(i, a, b) for(int i=(b-1); i>=(a);i--)
#define PER(i, n) for(int i=n-1; i>=0;i--)
using namespace std;


class Mod {
public:
  ll var;
  ll MOD = 1e9 + 7;
  const int MaxIntPower = 60;
  Mod(ll v = 0) { var = v; }
  void operator = (ll r) { var = r % MOD; }
  void operator = (Mod r) { var = r.var; }
  Mod operator + (Mod r) { return (var + r.var) % MOD; }
  Mod operator - (Mod r) { return (var - r.var + MOD) % MOD; }
  Mod operator * (Mod r) { return (var * r.var) % MOD; }
  Mod operator / (Mod r) { return (var * r.Reverse().var) % MOD; }

  void operator += (Mod r) { var = (var + r.var) % MOD; }
  void operator -= (Mod r) { var = (var - r.var + MOD) % MOD; }
  void operator *= (Mod r) { var = (var * r.var) % MOD; }
  void operator /= (Mod r) { var = (var + r.Reverse().var) % MOD; }

  bool operator ==(const Mod& r) { return var == r.var; }
  bool operator <(const Mod& r) { return var < r.var; }
  bool operator !=(const Mod& r) { return var != r.var; }

  Mod Power(ll p) {
    if (var == 0 || var == 1) return var;
    //while (p < 0) p += MOD - 1;
    //p = p % (MOD - 1);
    ll bit = ll(1) << MaxIntPower;
    Mod ans = 1;
    ans.MOD = MOD;
    while (bit >= 1) {
      ans *= ans;
      if ((bit & p) != 0)
        ans *= var;
      bit = (bit >> 1);
    }
    return ans;
  }

  Mod Reverse() {
    ll a = var;
    ll b = MOD;
    ll u = 1;
    ll v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }

    Mod val;
    val.var = (u + MOD) % MOD;
    return val;
  }
};

int main() {
  ll n, m;
  cin >> n >> m;



  Mod x = 10;
  x.MOD = m * m;
  Mod ans = x.Power(n);
  
  cout << (ans.var / m) % m;
  return 0;
}