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

#DSU0000008. Loại bỏ chu trình (Don’t be cycle)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Loại bỏ chu trình (Don’t be cycle)

Don’t be cycle

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a simple undirected graph with nn vertices and mm edges. You may remove edges. Find the minimum number of edges that must be removed so that the graph contains no cycles.

Input

The first line contains two integers n,mn,m. Each of the following mm lines contains two integers a,ba,b, describing an undirected edge. Vertices are numbered from 11 to nn.

Output

Print the minimum number of edges to remove.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1501\le n\le 150; 0≤m≤1700\le m\le 170; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b; no repeated edges.
  • Subtask 2 (30 points): 1≤n≤100001\le n\le 10000; 0≤m≤60000\le m\le 6000; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b; no repeated edges.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 0≤m≤2000000\le m\le 200000; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b; no repeated edges.

Examples

Input

6 7
1 2
1 3
2 3
4 2
6 5
4 6
4 5

Output

2

Explanation

Two independent cycles each require one removed edge, so the answer is 2.