Competition#2983

Competition

0.1 seconds
64 megabytes
Medium

In a sports tournament, there are participants, each with a unique number from to . The tournament uses a round-robin system: each participant must play one match against every other participant, and each match ends with a win for one of the players. A participant is considered to take position at the end of the tournament if:

  1. they have defeated exactly (P-1) participants and all the other participants have lost to them;

  2. every participant who has defeated them has also won against all participants that they have defeated.

For the remaining participants, it is not possible to determine their final position.

Write a program CONTEST that takes the number and the results of the matches already played in the tournament as input, and determines the number of participants whose final positions cannot be determined, regardless of the outcome of the remaining matches.

Input

The first line of the input contains two natural numbers: — the number of participants in the tournament (1 \leq N \leq 100) and — the number of games already played. The next lines each describe a match: two numbers are given, the winner's number and the loser's number.

Output

The output should be a single line containing the integer — the number of participants whose final position cannot be determined.

Examples

Example 1

Loading
Loading