Under construction

Still being built. Things may change

Delivery robots

Time limit1sMemory limit1024 MB

Summary
Given a connected undirected graph, find the largest number of vertices that can lie on simple paths from a chosen start s to a chosen end f.
Level

Medium7 of 10

Topics
Graph, DFS, Tree
Solved
No attempts yet

Problem

Juku likes hot dogs. A lot.

Juku lives in a town with VV intersections and EE two-way streets connecting them. The intersections are numbered 1…V1 \ldots V. No pair of intersections is connected by more than one street, and no street connects an intersection to itself. From every intersection, it is possible to reach every other intersection along the streets. Each intersection has a hot dog stand.

Juku is building delivery robots to bring him hot dogs. He chooses two intersections, the initial location of the robots ss and his own location ff, and programs the robots so that he gets hot dogs from as many different stands as possible.

Programming the robots is limited. Each robot can store an array nn and a variable bb. A robot starts moving from intersection ss and repeats these steps:

  1. If the robot is at intersection bb, it buys a hot dog from the stand there.
  2. If the robot is at intersection ff, it gives the hot dog to Juku and stops.
  3. The robot moves to intersection n[i]n[i], where ii is its current location.

For every i∈1…Vi \in 1 \ldots V, there must be a street between intersections ii and n[i]n[i]. Otherwise the robot crashes.

Find the maximum number of different stands Juku can get hot dogs from, when he chooses ss and ff optimally and enters nn and bb into the robots optimally. The values ss and ff are the same for all robots, but nn and bb can differ for each robot. You may assume Juku can use arbitrarily many robots.

Input

The first line contains two integers VV and EE, the number of intersections and the number of streets (1≤V≤1051 \le V \le 10^5, 1≤E≤3⋅1051 \le E \le 3 \cdot 10^5). Each of the next EE lines contains two integers uu and vv, meaning there is a street between intersections uu and vv.

Output

Print a single integer: the maximum number of different stands Juku can get hot dogs from.

Examples1

  1. Example 1

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