#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<iomanip>
#include<map>
#include<numeric>
#include<optional>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#pragma GCC optimize("Ofast")
namespace gengar
{
	using namespace std;
	#define int long long
	#define itn int
	#define uint unsigned long long
	#define ld long double
	#define vt(tp) vector<tp>
	#define vvt(tp) vector<vector<tp>>
	#define vvt2(nm,tp,h,w,n) vector<vector<tp>>nm((h),vector<tp>(w,n))
	#define P pair<int,int>
	#define hmap unordered_map
	#define hset unordered_set
	#define all(x) x.begin(),x.end()
	#define nsort(x) sort(all(x))
	#define rsort(x) nsort(x);reverse(all(x))
	#define unq(v) v.erase(unique(all(v)),v.end())
	#define l_b(c,x) distance(c.begin(),lower_bound(all(c),(x)))
	#define u_b(c,x) distance(c.begin(),upper_bound(all(c),(x)))
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define eb emplace_back
	#define spc ' '
	#define pass 
	#define _overload3(_1,_2,_3,name,...) name
	#define _rep(i,n) repi(i,0,n)
	#define repi(i,a,b) for(int i=(a),__SIZE##_=(b);i<__SIZE##_;i++)
	#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
	#define _daolrevo3(_1,_2,_3,name,...) name
	#define _per(i,n) peri(i,n,0)
	#define peri(i,a,b) for(int i=(a),__SIZE##_=(b);i>=__SIZE##_;i--)
	#define per(...) _daolrevo3(__VA_ARGS__,peri,_per,)(__VA_ARGS__)
	#define Bit(n) (1LL<<(n))
	#define myceil(a,b) ((a)+((b)-1))/(b)
	#define scale(n) cout<<fixed<<setprecision(n)
	using i64=int64_t;
	using u64=uint64_t;
	template<class T>using PQ=priority_queue<T,vt(T),greater<T>>;
	void in(){}
	template<class Car,class...Cdr>
	void in(Car&&car,Cdr&&...cdr){cin>>car;in(forward<Cdr>(cdr)...);}
	template<class T>void drop(T x){cout<<(x)<<endl;exit(0);}
	void dYes(){puts("Yes");exit(0);}
	void dNo(){puts("No");exit(0);}
	int gcd(int a,int b){return b?gcd(b,a%b):a;}
	int lcm(int a,int b){return a/gcd(a,b)*b;}
	int fact(int n,int m){int f=n;for(int i=n-1;i>=1;i--){f*=i;f%=m;}return f;}
	template<class T>int chmin(T&a,const T&b){if(b<a){a=b;return 1;}return 0;}
	template<class T>int chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
	const int inf=Bit(60);
	const double pi=acos(-1);
	const int mod=1000000007;//998244353
};
using namespace gengar;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	vector<pair<double,double>>lr(n);
	rep(i,n)
	{
		double t,l,r;cin>>t>>l>>r;
		if(t==2)r-=0.1;
		else if(t==3)l+=0.1;
		else if(t==4)r-=0.1,l+=0.1;
		lr[i].fi=l;lr[i].se=r;
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
	{
		if((lr[i].fi-lr[j].se)*(lr[j].fi-lr[i].se)>=0)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include <cmath>
#include <map>
#define ll long long
using namespace std;

int main(void){
  int num;
  cin >> num;
  vector<ll> coins(num);
  ll pay;
  cin >> pay;
  for(int i = 0;i < num;i ++){
    cin >> coins[num-1-i];
  }
  vector<map<ll,int>> ans(num);
  ans[0][pay] = 1;
  for(int i = 0;i < num-1;i ++){
    for(auto x : ans[i]){
      ll p = x.first;
      p = p % coins[i];
      ll payi = (x.first - p)/coins[i];

          if(abs(payi)* coins[i] < coins[i-1] or i == 0){
        ans[i+1][x.first-payi*coins[i]] += x.second;
          }
      if(p != 0){
        if(p > 0){
          p -= coins[i];
          payi++;
        }else{
          p += coins[i];
          payi --;
        }
        if(i == 0){
        ans[i+1][x.first-payi*coins[i]] += x.second;
        }else{
          if(abs(payi)* coins[i] < coins[i-1]){
        ans[i+1][x.first-payi*coins[i]] += x.second;
          }
        }
      }
    }
  }
  ll sum = 0;
  for(auto x : ans[num-1]){
    sum = sum + x.second;
  }
  cout << sum << endl;
  
  
  return 0;
}