text: /*
   * Author : Siddhant Khare
   */
  #include <bits/stdc++.h>
  using namespace std;
  
  /*******  All Required define Pre-Processors and typedef Constants *******/
  #define ll long long
  #define ld long double
  #define arr array
  #define si(t) scanf("%d", &t)
  #define sl(t) scanf("%ld", &t)
  #define sll(t) scanf("%lld", &t)
  #define sc(t) scanf("%c", &t)
  #define ss(t) scanf("%s", &t)
  #define sf(t) scanf("%f", &t)
  #define slf(t) scanf("%lf", &t)
  #define pi(x) printf("%d\n", x)
  #define pl(x) printf("%ld\n", x)
  #define pll(x) printf("%lld\n", x)
  #define pf(x) printf("%f")
  #define sz(x) (int)(x).size()
  #define mem(a, b) memset(a, (b), sizeof(a))
  #define FOR(i, j, k, in) for (int i = j; i < k; i += in)
  #define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
  #define REP(i, j) FOR(i, 0, j, 1)
  #define RREP(i, j) RFOR(i, j, 0, 1)
  #define all(x) x.begin(), x.end()
  #define rall(cont) cont.end(), cont.begin()
  #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
  #define IN(A, B, C) assert(B <= A && A <= C)
  #define sortall(x) sort(all(x))
  #define mp make_pair
  #define pb push_back
  // #define INF (int)1e9
  #define EPS 1e-9
  #define PI 3.1415926535897932384626433832795
  // #define MOD 1000000007
  #define read(type) readInt<type>()
  const double pi = acos(-1.0);
  typedef pair<int, int> PII;
  typedef vector<int> VI;
  typedef vector<string> VS;
  typedef vector<PII> VII;
  typedef vector<VI> VVI;
  typedef map<int, int> MPII;
  typedef set<int> SETI;
  typedef multiset<int> MSETI;
  
  /**************************************/
  
  /******** User-defined Function *******/
  int powmod(ll x, ll y, ll mod)
  {
      if (y == 0)
          return 1;
      ll p = powmod(x, y / 2, mod) % mod;
      p = (p * p) % mod;
      return (y % 2 == 0) ? p : (x * p) % mod;
  }
  
  /**************************************/
  
  /********** Main()  function **********/
  
  // Driver code
  
  signed main()
  {
      ll n, m;
      cin >> n >> m;
      ll x = powmod(10, n, m);
      ll y = (powmod(10, n, m * m) - x + m * m) % (m * m);
      cout << y / m << endl;
  }
  /********  Main() Ends Here *************/
  