PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#DSU0000041. Phân nhóm bạn bè (Friends)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân nhóm bạn bè (Friends)

Friends

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn people numbered from 11 to nn, and you are given mm pairs of acquaintances. Friendship is considered undirected and transitive: if aa is a friend of bb, and bb is a friend of cc, then aa and cc are also regarded as friends. Thus, people linked by any chain of acquaintances belong to the same friendship circle.

Partition all nn people into groups, with each person assigned to exactly one group. No two distinct people in the same group may be friends under this definition. There are no restrictions between different groups.

Find the minimum number of groups in a valid partition.

Input

The first line contains n,mn,m. Each of the next mm lines contains ai,bia_i,b_i.

Output

Print the minimum number of groups.

Subtasks

  • Subtask 1 (20 points): 2≤n≤202\le n\le20, 0≤m≤200\le m\le20; 1≤ai,bi≤n1\le a_i,b_i\le n, ai≠bia_i\ne b_i; pairs may repeat.
  • Subtask 2 (30 points): 2≤n≤42002\le n\le4200, 0≤m≤42000\le m\le4200; 1≤ai,bi≤n1\le a_i,b_i\le n, ai≠bia_i\ne b_i; pairs may repeat.
  • Subtask 3 (50 points): 2≤n≤2⋅1052\le n\le2\cdot10^5, 0≤m≤2⋅1050\le m\le2\cdot10^5; 1≤ai,bi≤n1\le a_i,b_i\le n, ai≠bia_i\ne b_i; pairs may repeat.

Examples

Input

5 3
1 2
3 4
5 1

Output

3

Explanation

Friendship components are {1,2,5} and {3,4}. The three people in the largest component require three distinct groups; {1,3}, {2,4}, {5} is a valid partition.