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 Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();
    let m: usize = sc.next().unwrap();
    let mut xy: Vec<(usize, usize)> = vec![];
    for _ in 0..m {
        let x: usize = sc.next().unwrap();
        let y: usize = sc.next().unwrap();
        xy.push((x - 1, y - 1));
    }
    let mut bads = vec![false; n];
    let mut bs = vec![];
    for i in 0..n {
        println!("{:?}", i);
        let mut b = vec![-1; n];
        b[i] = m as i32;
        let mut bad = false;
        for i in (0..m).rev() {
            let (x, y) = xy[i];
            if b[x] >= 0 && b[y] >= 0 {
                bad = true;
            }
            if b[x] >= 0 {
                b[y] = i as i32;
            } else if b[y] >= 0 {
                b[x] = i as i32;
            }
        }
        println!("{:?}", b);
        for i in 0..m {
            let (x, y) = xy[i];
            if b[x] >= 0 && b[x] < i as i32 && b[y] == -1 {
                b[y] = i as i32;
            } else if b[y] >= 0 && b[y] < i as i32 && b[x] == -1 {
                b[x] = i as i32;
            }
        }
        println!("{:?} {}", b, bad);
        bs.push(b);
        bads[i] = bad;
    }
    let mut res = 0;
    for i in 0..n {
        for j in 0..i {
            if !bads[i] && !bads[j] {
                if bs[i][j] == -1 && bs[j][i] == -1 {
                    res += 1;
                }
            }
        }
    }
    println!("{}", res);
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next().unwrap());
/// assert_eq!(3.5, sc.next().unwrap());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}