#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll mod = 1e9 + 7;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
const int MAX_N = 1e6;

bool prm[MAX_N + 10];
vector<int> ps;

void prime(int N){
    for(int i = 2; i <= N; i++) prm[i] = true;
    for(int i = 2; i <= N; i++){
        if(prm[i]){
            ps.push_back(i);
            for(int j = i * 2; j <= N; j += i){
                prm[j] = false;
            }
        }
    }
}

template<class T>
vector<pair<T, int>> prime_fac(T N){
    vector<pair<T, int>> res;
    T cp = N;
    for(ll i = 0; i < (int)ps.size() && ps[i] * ps[i] <= cp; ++i){
        int cnt = 0;
        while(N % ps[i] == 0) N /= ps[i], cnt++;
        if(cnt != 0) res.push_back({ps[i], cnt});
        
    }
    if(N != 1) res.push_back({N, 1});
    return res;
}

ll fastpow(ll x, ll y) {
    if (y == 0) return 1;
    ll e = fastpow(x, y / 2);
    return e * e * (y & 1 ? x : 1);
}

vector<pii> fac[MAX_N + 10];

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int L, R;
    cin >> L >> R;
    prime(MAX_N);
    for (int i = 1; i <= MAX_N; i++) {
        fac[i] = prime_fac(i);
    }
    ll ans = 0;
    for (int i = 2; i <= R; i++) {
        int l = max((L - 1) / i + 1, 2);
        int r = R / i;
        if (r < 3) break;

        for (int j = l; j <= r; j++) {
            for (int k = 0; k < (1 << fac[j].size()); k++) {
                int fil = 1;
                int cnt = 0;
                for (int x = 0; x < fac[j].size(); x++) {
                    if ((k >> x) & 1) {
                        cnt++;
                        fil *= fac[j][x].first;
                    }
                }
                int num = (r / fil) - ((l - 1) / fil);
                if (cnt & 1) ans -= num;
                else ans += num;
            }
        }
    }
    cout << ans << endl;
}
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>
#include <ctype.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = 1e18;

#define rep(i, n) for (int i = 0; i < n; i++)

template<class T> 
bool chmax(T &a, T b) {if (a < b) {a = b;return true;}else return false;}

template<class T> 
bool chmin(T &a, T b) {if (a > b) {a = b;return true;}else return false;}

ll mod_pow(ll a, ll n, ll p) {
    ll  ans = 1, tmp = a % p;
    while (n > 0) {
        if (n % 2)
            ans = ans * tmp % p;
        tmp = tmp * tmp % p;
        n /= 2;
    }
    return ans;
}



int main() {
    ll n, m;    cin >> n >> m;
    cout << mod_pow(10, n, m*m) / m << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;