CF919D Substring

Description

You are given a graph with $ n $ nodes and $ m $ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of that path is $ 3 $ . Your task is find a path whose value is the largest.

Input Format

The first line contains two positive integers $ n,m $ ( $ 1

Output Format

Output a single line with a single integer denoting the largest value. If the value can be arbitrarily large, output -1 instead.

Explanation/Hint

In the first sample, the path with largest value is $ 1→3→4→5 $ . The value is $ 3 $ because the letter 'a' appears $ 3 $ times.