#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
V<ll> p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
int main(){
  ll a,b;
  cin>>a>>b;
  V<ll> dp((1<<20),0);
  dp[0]=1;
  V<ll> tmp={};
  for(ll i=a;i<=b;i++){
        ll v=0;
        for(int j=0;j<20;j++){
            if(i%p[j]==0)v+=(1ll<<j);
        }
        tmp.emplace_back(v);
  }
  int m=tmp.size();
  for(int i=0;i<m;i++){
      for(ll j=0;j<(1<<20);j++){
          if((j&tmp[i])>0)continue;
          dp[j|tmp[i]]+=dp[j];
      }
  }
  ll ans=0;
  for(int i=0;i<(1<<20);i++)ans+=dp[i];
  cout<<ans<<"\n";
}
#include<bits/stdc++.h>
#define f(i,n) for(long long int i = 0 ; i < n;  i++)
#define F first
#define S second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define all(s) s.begin(), s.end()
#define u_s unordered_set
#define u_m unordered_map
#define ll long long int
#define pb push_back
#define pll pair<ll,ll>
#define parr(arr) for(auto x: arr)cout<<x<<" ";cout<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define testcase ll tt; cin>>tt; while(tt--)
using namespace std;

ll solve(){
    ll n; cin>>n;
    vector<array<ll,3>> v;
    f(i,n){
        ll op; cin>>op;
        ll l, r; cin>>l>>r;
        v.pb({op, l, r});
    }
    ll ans = 0;
    map<int,string> m;
    m[1] = "[]";
    m[2] = "[)";
    m[3] = "(]";
    m[4] = "()";
    f(i,n){
        ll opi = v[i][0];
        string opis = m[opi];
        ll si = v[i][1];
        ll ei = v[i][2];
        for(ll j = i+1; j < n; j++){
            ll opj = v[j][0];
            string opjs = m[opj];
            ll sj = v[j][1];
            ll ej = v[j][2];
            bool flag1, flag2;
            if(opjs[0] == '(' || opis[1] == ')'){
                flag1 = (sj >= ei);
            }else{
                flag1 = (sj > ei);
            }
            if(opjs[1] == ')' || opis[0] == '('){
                flag2 = (ej <= si);
            }else{
                flag2 = (ej < si);
            }
            if(!(flag1 || flag2)) ans++;
        }
    }
    return ans;
}

int main() {
    fast;
    cout<<solve();  
	return 0;
}