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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC177_D
{
    using static Ex;
    public class D
    {
        public static void Main(string[] args)
        {
            new ABC();
        }
    }

    public class ABC
    {
        public ABC()
        {
            var (n, m) = ReadIntArray().ToTpl2();
            var u = new UnionFind(n);
            for (int i = 0; i < m; i++)
            {
                var (a, b) = ReadIntArray().ToTpl2();
                a--; b--;
                u.Union(a, b);
            }
            long max = 0;
            for (int i = 0; i < n; i++)
            {
                Maxs(ref max, u.Size(i));
            }
            max.Cw();
        }
    }

    public class UnionFind
    {
        // 親要素のインデックスを保持する
        // 親要素が存在しない(自身がルートである)とき、マイナスでグループの要素数を持つ
        public int[] Parents { get; set; }
        public UnionFind(int n)
        {
            this.Parents = new int[n];
            for (int i = 0; i < n; i++)
            {
                // 初期状態ではそれぞれが別のグループ(ルートは自分自身)
                // ルートなのでマイナスで要素数(1個)を保持する
                this.Parents[i] = -1;
            }
        }

        // 要素xのルート要素はどれか
        public int Find(int x)
        {
            // 親がマイナスの場合は自分自身がルート
            if (this.Parents[x] < 0) return x;
            // ルートが見つかるまで再帰的に探す
            // 見つかったルートにつなぎかえる
            this.Parents[x] = Find(this.Parents[x]);
            return this.Parents[x];
        }

        // 要素xの属するグループの要素数を取得する
        public int Size(int x)
        {
            // ルート要素を取得して、サイズを取得して返す
            return -this.Parents[this.Find(x)];
        }

        // 要素x, yが同じグループかどうか判定する
        public bool Same(int x, int y)
        {
            return this.Find(x) == this.Find(y);
        }

        // 要素x, yが属するグループを同じグループにまとめる
        public bool Union(int x, int y)
        {
            // x, y のルート
            x = this.Find(x);
            y = this.Find(y);
            // すでに同じグループの場合処理しない
            if (x == y) return false;

            // 要素数が少ないグループを多いほうに書き換えたい
            if (this.Size(x) < this.Size(y))
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            // まとめる先のグループの要素数を更新
            this.Parents[x] += this.Parents[y];
            // まとめられるグループのルートの親を書き換え
            this.Parents[y] = x;
            return true;
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }

        public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
        public static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }
    }
}