cho.sh
Notes
Loading...

Number of Vertex Cactus Components

Time limit

2s

Memory limit

128 MB

Problem

A vertex cactus is a connected undirected graph with the following property.

  • Each vertex belongs to at most one simple cycle.

A simple cycle is a cycle in which every vertex, except for the repeated start/end vertex, appears at most once.

The following picture shows a vertex cactus.

You are given an undirected graph G with N vertices numbered from 1 to N, together with all of its edges. Count how many connected components of G are vertex cacti.

A connected component is a set of vertices such that every pair of vertices in the set is connected by a path, and no vertex in the set is connected to any vertex outside the set.

Input

The first line contains two integers N and M, the number of vertices and edges in G. N is a positive integer not greater than 200, and M is a nonnegative integer.

Each of the next M lines contains two space-separated integers describing one edge. No edge is repeated, and every pair of vertices is connected by at most one edge.

Output

Print one integer: the number of connected components of G that are vertex cacti.