Submit | All submissions | Best solutions | Back to list |
EITRGROUP - TOURISM |
ABC company has n employees numbered from 0. Each employee is managed by up to 1 other employee and has no cross-management (No trio exists: A manages B, B manages C, C manages A). The company wants to organize travel for its employees but the staff does not want to go with their superiors (the direct manager or higher) because they feel uncomfortable. The company will need to organize at least how many groups so there are no employees and superiors in the same group.
Note that the company has a director, not managed by any other employee.
Input
The first line contains the number of employees n, m (0 ≤ n, m ≤ 105) the number of employees and the number of management relationships.
The next m lines contain two integers u, v representing u as a direct manager of v.
Output
Minimum number of groups.
Example
Input:
5 4
2 4
4 1
3 2
3 0
Output:
4
Added by: | Ha Minh Ngoc |
Date: | 2018-07-29 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: GOSU |