#include <bits/stdc++.h>
#define MAXN 80
#define MAXM 1048576

using namespace std;


int P[20] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};

map <int,long long> mp[MAXN];

int main()
{
	long long A,B;
	cin>>A>>B;
	mp[0][0] = 1;
	for(long long i = A;i <= B;i++)
	{
		int sta = 0;
		for(int j=0;j<20;j++)
			if(i % P[j] == 0)
				sta += (1<<j);
		
		for(auto x:mp[i-A])
		{
			mp[i-A+1][x.first] += x.second;
			if((x.first & sta) == 0)
			{
				mp[i-A+1][x.first | sta] += x.second;
			}
		}
	}
	long long Ans = 0;
	for(auto x : mp[B-A+1])
		Ans += x.second;
	cout<<Ans;
	return 0;
}
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
ll modpow(ll pow, ll mod) {
	ll ret = 1, mult = 10;
	while (pow) {
		if (pow & 1) ret = (ret * mult) % mod;
		mult = (mult * mult) % mod;
		pow >>= 1;
	}
	return ret;
}
int main() {
	ll n, m;
	cin >> n >> m;
	cout << modpow(n, m * m) / m << endl;
}
