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

#DSU0000018. Các thành phần hình vòng (Cyclic Components)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Các thành phần hình vòng (Cyclic Components)

Cyclic Components

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a simple undirected graph with nn vertices and mm edges. A connected component is called a cyclic component if its vertices and edges form exactly one simple cycle of length at least three.

Count the cyclic components of the graph.

Input

The first line contains two integers n,mn,m. Each of the next mm lines contains two integers u,vu,v, describing an undirected edge. Vertices are numbered from 11 to nn.

Output

Print the number of cyclic connected components.

Subtasks

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

Examples

Input

5 4
1 2
3 4
5 4
3 5

Output

1

Explanation

Component {1,2} is just one edge, while {3,4,5} forms a 3-cycle, giving 1.