Lulu is a one-day courier on the mysterious sky islands. Lulu's job is to collect returned delivery boxes.
The people of the sky islands place returned boxes according to the following rules.
- Each bridge connecting two islands has exactly one returned delivery box on it.
- Each bridge has exactly one box.
- All box sizes are distinct.
Lulu also made the following rules.
- Whenever Lulu crosses a bridge, Lulu must collect the box on that bridge.
- Lulu never crosses the same bridge more than once.
- Boxes are stacked in the order they are collected. A box collected earlier is placed below a box collected later.
- Lulu must not place a larger box on top of a smaller box.
- Lulu cannot reorder the boxes.
- Lulu may choose any starting island.
Equivalently, the sizes of the boxes on the bridges Lulu crosses must be strictly decreasing in the order of traversal.
Find the maximum number of boxes Lulu can collect in one attempt while following all rules.
Input
The input is given in the following format.
is the number of islands, and is the number of bridges. The -th bridge connects islands and , and the size of the box on that bridge is .
Each line in the input represents one bridge. Multiple bridges may connect the same pair of islands.
Output
Print the maximum number of boxes Lulu can collect while following all rules.
Constraints
- .
- .
- ().
- ().
- are pairwise distinct.
Subtasks
Samples
루루는 순서로 이동할 수 있다.
이때 회수하는 상자의 크기는 이고, 순서대로 엄격히 감소하므로 규칙을 만족한다.
해설
관리자가 작성한 해설을 별도 페이지에서 볼 수 있어요.