#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 5555
int n, m, i, j, c[maxn], x[maxn], y[maxn], bad, it, k, used[maxn], gx[maxn], a[maxn][maxn], match[maxn], forbidden, de[maxn], tot, color[maxn];
bool wrong[maxn][maxn];
long long res;
int graph(int x){
return (x*(x-1))/2;
}
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
scanf("%d %d", &n, &m);
for(i = 1; i<=m; i++){
scanf("%d %d", &x[i], &y[i]);
if (x[i]>y[i]) swap(x[i], y[i]);
wrong[x[i]][y[i]] = 1;
a[x[i]][++c[x[i]]] = y[i];
}
for(i = 1; i<=n; i++){
gx[i] = 0;
for(j = 1; j<=m; j++) if (x[j]>i) ++gx[i];
}
res = n+graph(n)-m;
for(i = 1; i<=n; i++){
forbidden = c[i];
for(j = i+1; j<=n; j++) if (!wrong[i][j]){
match[j] = n - j - c[j] - forbidden;
for(k = 1; k<=c[j]; k++) if (wrong[i][a[j][k]]) ++match[j];
res += match[j];
}else --forbidden;
for(j = 1; j<=n; j++) de[j] = 0;
for(j = 1; j<=c[i]; j++) de[a[i][j]]=1; tot = c[i];
for(j = 1; j<i; j++) if (!wrong[j][i]){
for(k = 1; k<=c[j]; k++){
++de[a[j][k]];
if (de[a[j][k]]==1 && a[j][k]>i) ++tot;
}
res += graph(n-i-tot);
for(k = 1; k<=c[j]; k++){
--de[a[j][k]];
if (de[a[j][k]]==0 && a[j][k]>i) --tot;
}
}
}
for(i = 1; i<=m; i++){
for(j = 1; j<=n; j++) color[j] = 1;
tot = 0;
for(j = 1; j<x[i]; j++) if ((wrong[j][x[i]]||wrong[j][y[i]])==0){
color[j] = 0;
++tot;
}
res -= graph(tot);
for(j = 1; j<=m; j++) if (y[j]<x[i] && color[x[j]]+color[y[j]]==0) ++res;
}
cout << res << endl;
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29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