Delivery robots | 프로그래밍의 벗 PivotOJ
PivotOJ

Delivery robots

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2018-19 openBOJ 29938

문제

Juku likes hot dogs. A lot.

Juku lives in a town that has VV intersections and EE two-way streets connecting the intersections. Intersections have been numbered 1V1 \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 get to every other intersection along the streets. Also, there is a hot dog stand on every intersection.

Juku has started building delivery bots that would bring hot dogs to him. He wants to choose two intersections---initial location of robots ss and his own location ff---and code robots such that he could get hot dogs from as many different stands as possible.

Unfortunately, programming the robots is rather limited. Every robot can store an array nn and a variable bb in memory. Robot starts moving from intersection ss and repeats the following steps:

  1. If robot is located at intersection bb, it will buy a hot dog from the stand there.
  2. If robot is located at intersection ff, it will give the hot dog to Juku and stop.
  3. Robot moves to intersection n[i]n[i] where ii is its current location.

For every i1Vi \in 1 \ldots V there must be a street between intersections ii and n[i]n[i], otherwise the robot will crash.

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

입력

First line of input contains two integers VV and EE---numbers of intersections and streets (1V1051 \le V \le 10^5, 1E31051 \le E \le 3 \cdot 10^5). On the next EE lines there are two integers uu and vv on each, indicating a street between intersections uu and vv.

출력

The output should contain a single integer---the maximum number of different stands that Juku can get hot dogs from.

예제

예제 1

입력
6 6
1 2
2 3
3 1
4 1
5 2
6 3
출력
5
코드를 제출하려면 로그인하세요.