//2*10^9
//9*10^18
// __int128_t 
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long int
#define ll long long int

const ll M=1e9+7;

//to handle when remainder is -neg we add + M
//but when rem is +pos that time also we add so use %M
//so it will work for both
ll mod(ll n){
    return (n%M + M)%M; 
}
ll modAdd(ll a, ll b){
    return mod(mod(a)+mod(b));
}
ll modMul(ll a, ll b){
    return mod(mod(a)*mod(b));
}
ll modMinus(ll a, ll b){
    return mod(mod(a)-mod(b));
}
ll modpow(ll x, ll n) 
{ 
    if (n == 0) 
        return 1%M;
    if (n == 1)
        return x%M; 
    ll u = modpow(x,n/2); 
    u = modMul(u,u); 
    if (n%2) 
        u = modMul(u,x); 
    return u; 
}



ll mod1(ll n, ll mod){
    return (n%mod + mod)%mod; 
}
ll modMul1(ll a, ll b, ll mod){
    return mod1(mod1(a,mod)*mod1(b,mod),mod);
}
ll modpow1(ll x, ll n, ll mod) 
{ 
    if (n == 0) 
        return 1%mod;
    if (n == 1)
        return x%mod; 
    ll u = modpow1(x,n/2,mod); 
    u = modMul1(u,u,mod); 
    if (n%2) 
        u = modMul1(u,x,mod); 
    return u; 
}

ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isPrime(ll n){
    int end = sqrt(n);
    for(int i=2;i<=end;i++)
        if(n%i==0)
            return false;
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    int t=1;
    //cin>>t;

    while(t--){
        ll n,m;
        cin>>n>>m;

        ll result = modpow1(10,n,m*m);
        cout<<(result/m)%m<<endl;
    }
    return 0;
}


















#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

int V,E;
vector<ll> A;

struct Edge{
  int to;
  ll cost;
  Edge(int to, ll cost):to(to),cost(cost){}
};

template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color){
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++){
      if(color[e->to] == 2)continue;//このvisit以外のvisitで訪れた
      if(color[e->to] == 1)return false;//このvisitで訪れた
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order){
  int SizeG = G.size();
  vector<int> color(SizeG); 
  for(int u=0;u<SizeG;u++) if(!color[u] && !visit(G,u,order,color)) return false;
  reverse(order.begin(),order.end());
  return true;
}

int main() {
  cin >> V >> E;
  vector<vector<Edge>> G(V);
  A.resize(V);
  rep(i,V) cin >> A[i];
  int s,t;
  rep(i,E) {
    cin >> s >> t;
    --s, --t;
    G[s].pb((Edge){t,0});
  }
  vector<int> order;
  assert( topologicalSort(G,order) );
  reverse(ALL(order));
  if(0) {
    rep(i,(int)order.size()){
      cout << order[i]+1 << endl;
    }
  }

  ll ans = -LLONG_MAX;
  vector<ll> maxi(V,-1);
  rep(i,(int)order.size()) {
    int v = order[i];
    ll tmp_maxi = -1;
    rep(j,(int) G[v].size()) {
      int t = G[v][j].to;
      tmp_maxi = max(tmp_maxi, maxi[t]);
    }
    if( tmp_maxi != -1LL ) {
      ans = max(ans,tmp_maxi - A[v]);
    }
    tmp_maxi = max(tmp_maxi,A[v]);
    maxi[v] = tmp_maxi;
  }
  cout << ans << endl;
  
  return 0;
}
