#C6653. Maximum Span of Control

    ID: 50437 Type: Default 1000ms 256MiB

Maximum Span of Control

Maximum Span of Control

In a company, every employee is assigned a unique ID from 1 to \(n\). A direct reporting relationship is given as a pair of integers \((a, b)\) where employee \(a\) is the direct supervisor of employee \(b\). The span of control of an employee is defined as the total number of employees under their supervision, both directly and indirectly.

Given the number of employees and a list of direct relationships, your task is to compute the maximum span of control among all employees. In other words, for each employee, determine how many employees they supervise (directly or indirectly), and then find the maximum value among these counts.

Note: The span of control does not include the employee themselves.

Example:
For \(n = 6\) and relationships \((1, 2), (1, 3), (2, 4), (2, 5), (3, 6)\), the employee 1 indirectly or directly supervises 5 employees, so the answer is 5.

inputFormat

The input is read from standard input (stdin).

The first line contains a single integer (n) denoting the number of employees. The second line contains a single integer (m) denoting the number of direct supervisor relationships. Each of the next (m) lines contains two space-separated integers (a) and (b) indicating that employee (a) is the direct supervisor of employee (b>.

outputFormat

Output a single integer to standard output (stdout) which is the maximum span of control among all employees.## sample

1
0
0