Problem:
Score : 1400 points

Problem Statement

There are N turkeys.
We number them from 1 through N.

M men will visit here one by one.
The i-th man to visit will take the following action:

If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it.

If either turkey x_i or y_i is alive (but not both): eats the alive one.

If neither turkey x_i nor y_i is alive: does nothing.

Find the number of pairs (i,\ j) (1 ≤ i < j ≤ N) such that the following condition is held:

The probability of both turkeys i and j being alive after all the men took actions, is greater than 0.

Constraints

2 ≤ N ≤ 400

1 ≤ M ≤ 10^5

1 ≤ x_i < y_i ≤ N

Input

Input is given from Standard Input in the following format:

N M
x_1 y_1
x_2 y_2
:
x_M y_M

Output

Print the number of pairs (i,\ j) (1 ≤ i < j ≤ N) such that the condition is held.

Sample Input 1

3 1
1 2

Sample Output 1

2

(i,\ j) = (1,\ 3), (2,\ 3) satisfy the condition.

Sample Input 2

4 3
1 2
3 4
2 3

Sample Output 2

1

(i,\ j) = (1,\ 4) satisfies the condition.
Both turkeys 1 and 4 are alive if:

The first man eats turkey 2.

The second man eats turkey 3.

The third man does nothing.

Sample Input 3

3 2
1 2
1 2

Sample Output 3

0

Sample Input 4

10 10
8 9
2 8
4 6
4 9
7 8
2 8
1 8
3 4
3 4
2 7

Sample Output 4

5

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<stdio.h>
/*
(a,b)のうち両方が生き残っている場合が存在することを、「ペアで生き残る」と呼ぶ。
(a,b)のうちどちらかを食べる人が来たとき、次のようになる：
(a,b)→ペアで生き残ることはない。
(x,y)→変わらない。
(a,x)→ちょっと考えると、これがペアで生き残る必要十分条件は、
       (a,b)と(b,x)がどちらもペアで生き残っていることである。
*/

int N,M,x[100000],y[100000];
int i,j, alive[400][400],memox[400],memoy[400];/*生→1, 死→0*/
int ans;

int main(void){



	scanf("%d %d", &N, &M);
	for(i=0;i<M;i++){
		scanf("%d %d", &x[i], &y[i]);
		x[i]--;
		y[i]--;
	}

	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			alive[i][j] = 1;
		}
	}

	for(i=0;i<M;i++){
		for(j=0;j<N;j++){
			/*(x[i], j)について*/
			if(x[i]!=j){
				if(alive[x[i]][y[i]] == 0 || alive[y[i]][j] == 0){
					memox[j] = 0;	
				}else{
					memox[j] = 1;
				}
			}

			/*(y[i], j)について*/
			if(y[i]!=j){
				if(alive[x[i]][y[i]] == 0 || alive[x[i]][j] == 0){
					memoy[j] = 0;
				}else{
					memoy[j] = 1;
				}
			}
		}

		for(j=0;j<N;j++){
			if(x[i]!=j){
				alive[x[i]][j] = alive[x[i]][j]*memox[j];
				alive[j][x[i]] = alive[j][x[i]]*memox[j];
			}
			if(y[i]!=j){
				alive[y[i]][j] = alive[y[i]][j]*memoy[j];
				alive[j][y[i]] = alive[j][y[i]]*memoy[j];
			}
		}

		alive[x[i]][y[i]] = 0;
		alive[y[i]][x[i]] = 0;

	}

	ans = 0;
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			if(alive[i][j] == 1){
				ans++;
			}
		}
	}
	printf("%d\n",ans);
}