#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e6;
typedef int fuko[yuzu|10];
fuko vis;
int main() {
  ll n,m,i;
  auto kasumi=[&](ll a,ll b,int mod) {
    ll zw=1;
    for (;b;b>>=1,a=a*a%mod) if (b&1) zw=zw*a%mod;
    return zw;
  };
  read(n),read(m);
  printf("%lld\n",kasumi(10,n,m*m)/m%m);
}
#include <cstdio>

int po(int a, long long b, int m) 
{
	int r = 1;
	while (b) {
		if (b & 1) r = (long long)r * a % m;
		a = (long long)a * a % m;
		b >>= 1;
	}
	return r;
}

int m;
long long n;

int main() 
{
	scanf("%lld%d", &n, &m);
	printf("%d\n", (po(10, n, m * m) - po(10, n, m)) / m);
	return 0;
}
