#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
dp[i][S]=a[i]まで決まったときに使った集合がSであり条件を満たす場合の数
dp[S]=Sまで決まったときに条件を満たす場合の数

条件を満たさない場合はdp[i][S]=0にする
未訪問をdp[i][S]=-1にする
ans:dp[n][(1<<n)-1]
*/

ll n,m;
vector<ll>x,y,z;

vector<ll>dp;

ll rec(ll S){
	if(dp[S]!=-1)return dp[S];
	//条件を満たすかcheck
	int cnt = __builtin_popcount(S);
	rep(i,m){
		if(cnt!=x[i])continue;
		int now = 0;
		rep(j,y[i]){
			if((S>>j)&1)now++;
		}
		if(now>z[i]){
			return dp[S] = 0;
		}
	}
	ll res = 0;
	rep(i,n){
		if((S>>i)&1){
			res += rec(S^(1<<i));
		}
	}
	return dp[S] = res;
}


int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin >> n >> m;
	x.resize(m);
	y.resize(m);
	z.resize(m);
	rep(i,m)cin>>x[i]>>y[i]>>z[i];
	dp.resize((1<<n),-1);
	dp[0]=1;
	cout << rec((1<<n)-1) << endl;
	//debug(dp);

	return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   int  long long
#define    pii pair<int,int>
#define   vi vector<int >
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define    F first
#define    S second
#define   endl  "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl

const int  N = 2e5 + 1;
const int  inf = 1e18 + 3;
const int  ninf = -1e9 ;
const int  mod = 1e9 + 7;
//--------------------------------------------------------------//

int find(int x)
{
    int r = 0;
    while (x)
    {
        r += (x % 10);
        x = x / 10;
    }
    return r;
}

void solve()
{
    int n; cin >> n;

    vector<pair<double, double>>v;

    rep(i, 0, n)
    {
        int x, y; cin >> x >> y;
        v.pb({x, y});
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double  m = ((v[j].S - v[i].S) / (v[j].F - v[i].F));

            if (m <= (double)1  and  m >= (double) - 1)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;




}

signed main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    FASTIO;
    int T = 1;
    //cin >> T;

    for (int t = 1; t <= T; t++)
    {
        solve();
    }
    return 0;
}