#P10938. Vani和Cl2捉迷藏

Vani和Cl2捉迷藏

Problem Description

Vani and cl2 are playing hide-and-seek in a forest.

There are NN houses and MM directed roads in the forest, forming a directed acyclic graph.

The trees in the forest are very dense and can block the line of sight, but along the roads the view is clear.

If one can walk from house AA along the roads and reach BB, then people in AA and BB can see each other.

Now cl2 wants to choose KK of the NN houses as hiding places, and Vani will only enter the houses that cl2 chose to search. To avoid being seen by Vani, cl2 requires that for any two of these KK hiding places, there is no path connecting them.

To make it harder for Vani to find him, cl2 wants to know the maximum number of hiding places that can be chosen.

Input Format

The first line of the input contains two integers NN and MM.

The next MM lines each contain two integers x,yx,y, indicating a directed road from xx to yy.

Output Format

Output one integer, the maximum number of hiding places that can be chosen.

4 4
1 2
3 2
3 4
4 2
2

Hint

  • For 20%20\% of the testdata, 1N101\leq N\leq 10, 1M201\leq M\leq 20.
  • For 60%60\% of the testdata, 1N1001\leq N\leq 100, 1M10001\leq M\leq 1000.
  • For 100%100\% of the testdata, 1N2001\leq N\leq 200, 1M300001\leq M\leq 30000, 1x,yN1\leq x,y\leq N.

Translated by ChatGPT 5