#include<iostream>
#include<cstdio>
using namespace std;
const int maxm = 100000 + 100;
int n, m;
int op[maxm], u[maxm], v[maxm];
int ans;
int g[10][10];
int main()
{
freopen("tria.in","r",stdin);
freopen("tria.out","w",stdout);
cin >> n >> m;
int sum = n*(n-1)*(n-2)/6;
for (int i = 1; i <= m; i++)
cin >> op[i] >> u[i] >> v[i];
if (m == 0)
{
if (n == 4)
ans = 8;
else
ans = 4 * sum;
}
else
ans = 0;
cout << ans;
return 0;
}