#include<bits/stdc++.h>
using namespace std;
long long a,b,len;
typedef long long ll;
ll dp[75][1<<20],pk;
vector<long long> m,p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
int main()
{
    cin>>a>>b;
    len=b-a+1;
    for(ll i=a;i<=b;i++) m.push_back(i);
    pk=p.size();
    dp[0][0]=1;
    for(ll i=0;i<len;i++){
        ll nowb=0;
        for(ll j=0;j<pk;j++)
            if(m[i]%p[j]==0) nowb=nowb|(1<<j);//是哪一个质数的倍数       
        for(ll j=0;j<(1<<pk);j++){
            if(i==0){
                if(nowb==j)
                dp[i][j]+=1;
            }
            else{
                dp[i][j]=dp[i-1][j];

                if((nowb&j)==nowb)
                    dp[i][j]+=dp[i-1][j-nowb];
            }
        }       
    }
    long long res=0;
    for(ll i=0;i<(1<<pk);i++)
        res+=dp[len-1][i];
    cout<<res<<endl;
    system("pause");
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define pow(n,m) powl(n,m)
#define sqrt(n) sqrtl(n)
const ll MAX = 5000000000000000000;
const ll MOD = 0;
void randinit(){srand((unsigned)time(NULL));}
int main(){
    ll N,M;
    cin >> N >> M;
    vector<tuple<ll,ll>> A(0);
    for(ll i = 0;i < M;i++){
        ll x,y;
        cin >> x >> y;
        if(N - 250000 <= y && y <= N + 250000){
            A.emplace_back(make_tuple(x,y));
        }
    }
    sort(A.begin(),A.end());
    vector<ll> DP(600000,0);
    DP[300000] = 1;
    for(ll i = 0;i < A.size();i++){
        vector<ll> B(0);
        while(true){
            ll y = get<1>(A[i]);
            B.emplace_back(y);
            if(i < A.size() - 1 && get<0>(A[i]) == get<0>(A[i + 1])){
                i++;
            }
            else{
                break;
            }
        }
        map<ll,ll> kari;
        for(ll j = 0;j < B.size();j++){
            kari[B[j] - N + 300000] = DP[B[j] - N + 300000];
            if(B[j] > 0){
                kari[B[j] - N + 300000 - 1] = DP[B[j] - N + 300000 - 1];
            }
            if(B[j] < 2 * N){
                kari[B[j] - N + 300000 + 1] = DP[B[j] - N + 300000 + 1];
            }
        }
        for(ll j = 0;j < B.size();j++){
            DP[B[j] - N + 300000] = 0;
        }
        for(ll j = 0;j < B.size();j++){
            if(B[j] > 0 && kari[B[j] - N + 300000 - 1]){
                DP[B[j] - N + 300000] = 1;
            }
            if(B[j] < 2 * N && kari[B[j] - N + 300000 + 1]){
                DP[B[j] - N + 300000] = 1;
            }
        }
    }
    ll ans = 0;
    for(ll i = 0;i < DP.size();i++) ans += DP[i];
    cout << ans << endl;
}
