CF1209D.Cow and Snacks

传统题 时间 2000 ms 内存 256 MiB 9 尝试 3 已通过 1 标签

Cow and Snacks

The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!

There are nn snacks flavors, numbered with integers 1,2,,n1, 2, \ldots, n. Bessie has nn snacks, one snack of each flavor. Every guest has exactly two favorite flavors. The procedure for eating snacks will go as follows:

  • First, Bessie will line up the guests in some way.
  • Then in this order, guests will approach the snacks one by one.
  • Each guest in their turn will eat all remaining snacks of their favorite flavor. In case no favorite flavors are present when a guest goes up, they become very sad.

Help Bessie to minimize the number of sad guests by lining the guests in an optimal way.

Input

The first line contains integers nn and kk (2n1052 \le n \le 10^5, 1k1051 \le k \le 10^5), the number of snacks and the number of guests.

The ii-th of the following kk lines contains two integers xix_i and yiy_i (1xi,yin1 \le x_i, y_i \le n, xiyix_i \ne y_i), favorite snack flavors of the ii-th guest.

Output

Output one integer, the smallest possible number of sad guests.

Note

In the first example, Bessie can order the guests like this: 3,1,2,43, 1, 2, 4. Guest 33 goes first and eats snacks 11 and 44. Then the guest 11 goes and eats the snack 22 only, because the snack 11 has already been eaten. Similarly, the guest 22 goes up and eats the snack 33 only. All the snacks are gone, so the guest 44 will be sad.

In the second example, one optimal ordering is 2,1,3,5,42, 1, 3, 5, 4. All the guests will be satisfied.

Samples

5 4
1 2
4 3
1 4
3 4
1
6 5
2 3
2 1
3 4
6 5
4 5
0

在线编程 IDE

建议全屏模式获得最佳体验