This page is still under construction.

Parts of this page are still being built. What you see may change.

Tree Cutting Game

Time limit1sMemory limit1024 MB

Summary
Given a tree with 2^K-1 vertices, find the maximum of (vertices minus edges) GS can reach by removing vertices and re-joining components.
Level

Hard8 of 10

Topics
Tree, DFS, Greedy
Solved
No attempts yet

Problem

GS and CU play a tree cutting game on an acyclic undirected graph GG with N=2K−1N = 2^K - 1 vertices and MM edges. First, GS may repeat either of the following two actions as many times as desired.

  • remove v: Choose a vertex vv in GG, remove it, and remove all edges connected to vv.
  • join u v: Choose two vertices uu and vv that belong to different components of GG, and add an edge between them.

After GS finishes, CU may repeat either of the following two actions as many times as desired.

  • join u v: Choose two vertices uu and vv that belong to different components of GG, and add an edge between them.
  • slide u v w: When both the edge uu-vv and the edge vv-ww exist in GG, remove the edge uu-vv and add the edge uu-ww.

When CU finishes, CU wins if GG has two components with exactly the same shape. Otherwise, GS wins.

GS learned that removing all vertices wins easily. So GS decided to win by maximizing the value of (number of vertices) - (number of edges) in GG after GS finishes. Help GS plan a strategy.

Input

The first line contains the number of vertices NN and the number of edges MM of GG.

Each of the next MM lines contains two vertices uu and vv that are connected by an edge of GG, separated by a space.

Output

Print the value of (number of vertices) - (number of edges) in GG after GS finishes, using the strategy GS chose.

Constraints

  • 1≤N≤217−11 \le N \le 2^{17} - 1 (= 131071)
  • NN is guaranteed to satisfy N=2K−1N = 2^K - 1 for some integer KK.
  • N−20≤M≤N−1N - 20 \le M \le N - 1
  • 1≤u,v≤N1 \le u, v \le N, u≠vu \ne v

Hint

Two graphs HH and KK have exactly the same shape if you can number the vertices of HH and KK so that the sets of number pairs connected by edges are the same in both graphs.

Examples1

  1. Example 1

    Input
    7 6
    1 2
    2 3
    2 4
    2 5
    4 6
    6 7
    
    Expected output
    2