Under construction

Still being built. Things may change

Sea Urchin Field

Time limit1sMemory limit1024 MB

Summary
Given a sea urchin field graph, find the maximum number of urchins that can be gathered so that no two adjacent urchins are both picked.
Level

Medium7 of 10

Topics
Graph, BFS, DFS
Solved
No attempts yet

Problem

Dongeun, a native of Jeju Island, returned to Jeju after a long stay in the capital to carry on his family's trade. The son of the island's most skilled female diver, Dongeun decided to become a male diver like his parents wished. Now a new diver, he will practice diving and gather sea urchins alongside his mother. It is July to August, the sea urchin season, so there are a huge number of sea urchins in the sea.

Sea urchins can be represented as a graph made of vertices and undirected edges.

A sea urchin is a tree structure in T=(V,E)T=(V,E) where there is exactly one vertex c∈Vc \in V with deg⁡(c)=∣V∣−1\deg (c)= \lvert V \rvert - 1, and deg⁡(c)≥3\deg (c) \ge 3. In a sea urchin, the vertex cc is called the center, and all other vertices are called the spines.

A sea urchin field is a graph that has one or more sea urchins as subgraphs. Every vertex and edge of a sea urchin field belongs to at least one sea urchin.

If a vertex is the center of a sea urchin in a field, it is not included as the center or a spine of any other sea urchin. In other words, a center belongs to exactly one sea urchin.

The spines of two different sea urchins in a field may be shared. If two sea urchins share at least one spine, they are said to be adjacent.

Each sea urchin in a field is either female or male. Since this is sea urchin season, no two adjacent sea urchins are both female or both male.

Look at the following example. The sea urchin field in the figure has sea urchins with centers 1 and 7, which are adjacent through spines 2 and 3. Every vertex and edge belongs to at least one sea urchin, and the centers 1 and 7 each belong to exactly one sea urchin.

Dongeun wants to gather these sea urchins by diving into the sea. Because he cannot stay underwater for long, he can gather exactly one sea urchin per dive. When he gathers a sea urchin, the spines of the adjacent sea urchins break and lose their value, so he cannot gather any sea urchin adjacent to the one he has gathered.

To be specific, at the start every sea urchin can be gathered. When he dives and gathers a sea urchin that can still be gathered, every sea urchin adjacent to it can no longer be gathered. Dongeun wants to gather as many sea urchins as possible, diving as many times as he needs. Find the maximum number of sea urchins he can gather.

Input

The first line contains the number of vertices NN and the number of edges MM, separated by a space. (1≤N≤15 0001 \le N \le 15\,000, 1≤M≤30 0001 \le M \le 30\,000)

From the second line through the MMth line, each line contains two integers aia_i and bib_i, separated by a space, describing an edge. (1≤i≤M1 \le i \le M, 1≤ai,bi≤N1 \le a_i, b_i \le N, ai≠bia_i \neq b_i)

This means that vertex aia_i and vertex bib_i of the sea urchin field are connected by an undirected edge. No edge is given more than once.

The input is always a graph that satisfies the conditions of a sea urchin field.

Output

Print the maximum number of sea urchins Dongeun can gather.

Examples3

  1. Example 1

    Input
    4 3
    1 2
    1 3
    1 4
    
    Expected output
    1
    
  2. Example 2

    Input
    11 12
    1 2
    2 3
    2 4
    3 5
    4 5
    5 6
    6 7
    7 8
    7 9
    8 10
    9 10
    10 11
    
    Expected output
    2
    
  3. Example 3

    Input
    25 28
    1 2
    2 3
    2 4
    2 5
    2 7
    2 8
    2 12
    3 6
    4 6
    5 6
    7 9
    8 9
    9 10
    9 11
    12 13
    13 14
    13 15
    13 16
    13 22
    15 17
    16 17
    17 18
    17 19
    17 20
    17 21
    22 23
    23 24
    23 25
    
    Expected output
    4