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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define pb push_back
#define pob pop_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
/* unordered_map<int,int>mp; mp.reserve(1024); mp.max_load_factor(0.25); */
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 1e6 + 15;
const ll inf = 1e18;



void solve()
{
        ll l , r;
        cin >> l >> r;
        vll a(N);
        for(ll i = 2 ; i <= 1e6 ; i++ )
        {
                ll k = (r/i) - (l-1)/i;
                a[i] = (k*(k-1))/2;
        }
        for(ll i = 1e6 ; i >= 2 ; i-- )
        {
                for(ll j = 2*i ; j <= 1e6 ; j += i)
                        a[i] -= a[j];
        }
        ll ans = 0;
        for(ll i = 2 ; i <= 1e6 ; i++ )
        {
                if(i >= l and i <= r)
                {
                        a[i] -= ((r/i - (l-1)/i) - 1);
                }
                // if(i >= 2 and i <= 8)
                //         cout << i << " " << a[i] << endl;
        }
        for(ll i = 2 ; i <= 1e6 ; i++ )
                ans += a[i];
        cout << ans*2;
}         

void debug(ll tt) {}
 
signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}
// freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define mod 998244353
#define MOD 1000000007
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
// aのn乗を求める(modp)
int modPow(ll a, ll n, ll p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main(){
  ll n, m;
  cin >> n >> m;
  
  ll ans;
  ans = modPow(10, n, m*m);
  ans = ans / m;
  cout << ans << endl;
}