Water Supply

Technopark is a huge industrial park surrounded by small residential towns, inhabited by its workers. Technopark owns a dam, which provides electricity and clean drinking water to its facilities and some residential towns. The remaining towns get their water from dug wells. Recently, some workers and their families have gotten a disease caused by bacteria found in some wells, so it has been decided to extend the water supply network to take dam water from Technopark to every residential town. Some pipelines connecting pairs of towns already exist but additional pipelines could possibly be needed. Pipelines are unidirectional, i.e., they only allow water transportation in one direction, and every pipeline connects exactly two towns. Your task is to compute the minimum number of pipelines that must be installed to take dam water to every residential town. Input The input contains several test cases. The first line of each test case has two blank-separated integers N and M, where N is the number of residential towns (1 ≤ N ≤ 1000) and M is the number of existing pipelines (0 ≤ M ≤ 100000). Towns are numbered from 0 to N, being Technopark town 0. Each of the next M lines contains two blank-separated integers a and b (0 ≤ a ≤ N, 0 ≤ b ≤ N) indicating that there is a pipeline taking water from town a to town b. Output For each test case, print the minimum number of pipelines that must be built to take dam water to every residential town. Sample Input 45 01 12 21 04 34 42 31 21 Sample Output 1 3