#P40007. 2019 ICPC NCNA Regional Contest H - On Average They're Purple

2019 ICPC NCNA Regional Contest H - On Average They're Purple

题目描述

image.png

Alice colors each edge in the graph red or blue.

A path is a sequence of edges where each pair of consecutive edges have a node in common. If the first edge in the pair is of a different color than the second edge, then that is a ``color change.''

After Alice colors the graph, Bob chooses a path that begins at node 11 and ends at node NN. He can choose any path on the graph, but he wants to minimize the number of color changes in the path. Alice wants to choose an edge coloring to maximize the number of color changes Bob must make. What is the maximum number of color changes she can force Bob to make, regardless of which path he chooses?

输入格式

The first line contains two integer values NN and MM with 2N1000002 \le N \le 100\,000 and 1M1000001 \le M \le 100\,000. The next MM lines contain two integers aia_i and bib_i indicating an undirected edge between nodes aia_i and bib_i (1ai,biN1 \le a_i, b_i \le N, aibia_i \not= b_i).

All edges in the graph are unique.

输出格式

Output the maximum number of color changes Alice can force Bob to make on his route from node 11 to node NN.

样例

输入样例1

3 3
1 3
1 2
2 3

输出样例1

0

输入样例2

7 8
1 2
1 3
2 4
3 4
4 5
4 6
5 7
6 7

输出样例2

3