Problem:
Score : 400 points

Problem Statement

There are N persons called Person 1 through Person N.

You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times.

If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.

Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.

At least how many groups does he need to make?

Constraints

2 \leq N \leq 2\times 10^5

0 \leq M \leq 2\times 10^5

1\leq A_i,B_i\leq N

A_i \neq B_i

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
\vdots
A_M B_M

Output

Print the answer.

Sample Input 1

5 3
1 2
3 4
5 1

Sample Output 1

3

Dividing them into three groups such as \{1,3\}, \{2,4\}, and \{5\} achieves the goal.

Sample Input 2

4 10
1 2
2 1
1 2
2 1
1 2
1 3
1 4
2 3
2 4
3 4

Sample Output 2

4

Sample Input 3

10 4
3 1
4 1
5 9
2 6

Sample Output 3

3

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use proconio::marker::*;
use proconio::{fastout, input};
use rand::prelude::*;
use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ar: [(Usize1, Usize1); m],
    }
    let mut ar = ar;
    let res = solve(n, &mut ar);
    println!("{}", res);
    // randtest();
    // handtest();
}

fn handtest() {
    let n = 8;
    let mut ar = vec![(2, 1), (3, 2), (3, 0), (1, 5), (5, 6), (5, 7), (3, 0)];
    let res = solve(n, &mut ar);
    let tes = testsol(n, &mut ar);
    println!("{}: {:?}, {:?}", res == tes, res, tes);
}

fn randtest() {
    for _ in 0..50 {
        let mut rng = rand::thread_rng();
        let n = rng.gen_range(2, 10);
        let m = rng.gen_range(1, 10);
        let mut ar = Vec::with_capacity(m);
        for _ in 0..m {
            ar.push((rng.gen_range(0, n), rng.gen_range(0, n)));
        }
        let mut ar = ar;
        let res = solve(n, &mut ar);
        let tes = testsol(n, &mut ar);
        println!("{}: {}, {}", res == tes, res, tes);
        if res != tes {
            break;
        }
    }
}

fn solve(n: usize, ar: &mut [(usize, usize)]) -> usize {
    let mut friends: Vec<Option<usize>> = vec![None; n];
    let mut gmemo: Vec<HashSet<_>> = Vec::with_capacity(n);
    let mut gnum = 0;
    for a in ar {
        if let Some(b) = friends[a.0] {
            if let Some(c) = friends[a.1] {
                if !gmemo.iter_mut().any(|memo| {
                    let flag = memo.contains(&b) || memo.contains(&c);
                    if flag {
                        memo.insert(b);
                        memo.insert(c);
                    }
                    flag
                }) {
                    let mut thash = HashSet::with_capacity(n);
                    thash.insert(b);
                    thash.insert(c);
                    gmemo.push(thash);
                }
            } else {
                friends[a.1] = Some(b);
            }
        } else {
            if let Some(b) = friends[a.1] {
                friends[a.0] = Some(b);
            } else {
                friends[a.0] = Some(gnum);
                friends[a.1] = Some(gnum);
                gnum += 1;
            }
        }
    }

    let mut group = vec![0; n];
    for p in friends {
        if let Some(pi) = p {
            group[pi] += 1;
        }
    }

    group.into_iter().max().unwrap()
}

use std::collections::HashSet;
fn testsol(n: usize, ar: &mut [(usize, usize)]) -> usize {
    println!("{:?}", ar);
    let mut friends: Vec<HashSet<_>> = Vec::with_capacity(n);
    for a in ar {
        let mut flag = false;
        for f in friends.iter_mut() {
            if f.contains(&a.0) {
                f.insert(a.1);
                flag = true;
            }
            if f.contains(&a.1) {
                f.insert(a.0);
                flag = true;
            }
        }
        if flag {
            continue;
        }
        let mut nvec = HashSet::with_capacity(n);
        nvec.insert(a.0);
        nvec.insert(a.1);
        friends.push(nvec);
    }
    println!("t: {:?}", friends);
    friends.into_iter().map(|a| a.len()).max().unwrap()
}