#K62457. Company Hierarchy Levels
Company Hierarchy Levels
Company Hierarchy Levels
You are given a company hierarchy represented by n employees and a list of direct reporting relations. Each relation is given as a pair of integers x y, which means that employee y reports directly to employee x.
The company's hierarchy forms a tree with a single top-level employee (the root), who does not report to anyone. Your task is to determine the number of distinct levels in this hierarchy. (Level 1 is the root, level 2 contains the direct subordinates of the root, and so on.)
Note: The employees are numbered from 1 to n. It is guaranteed that the structure forms a valid tree.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer
n
, the number of employees. - The second line contains an integer
m
, the number of direct reporting relations. - Each of the following
m
lines contains two integersx
andy
indicating that employeey
reports directly to employeex
.
outputFormat
Output a single integer to stdout representing the number of distinct levels in the company hierarchy.
## sample7
6
1 2
1 3
2 4
2 5
3 6
3 7
3