#P3275. Candy Distribution
Candy Distribution
Candy Distribution
There are (N) children in a kindergarten. Teacher (lxhgww) wants to distribute candies to all of them so that every child gets at least one candy. However, due to jealousy, the children impose (K) requirements. For example, if a child does not want another child to receive more candies than him, then the requirement is (x_a \ge x_b) (where (x_a) and (x_b) denote the number of candies received by the two children respectively). Determine the minimum total number of candies required so that each child gets at least one candy and all the requirements are satisfied.
inputFormat
The first line contains two integers (N) and (K) ((1 \le N \le 10^5), (0 \le K \le 10^5)). Each of the following (K) lines contains two integers (a) and (b) ((1 \le a, b \le N) with (a \neq b)) indicating that the child numbered (a) does not want the child numbered (b) to receive more candies than him (i.e. the requirement is (x_a \ge x_b)).
outputFormat
Output a single integer representing the minimum total number of candies required.
sample
3 2
1 2
2 3
3
</p>