UOJ Logo 黑暗爆炸OJ

DARKBZOJ

#1950. [Ceoi2006]Link

统计 下载数据

Description

给 N个点N 条边的有向图。 要求添最小的边,使得点1 到达其他所有点的最短路长度不超过K。

Input

The first line of input contains two integers N and K (2 ≤ N ≤ 500 000, 1 ≤ K ≤ 20 000) – the number of pages and the target maximum number of links to be followed. Each of the following N lines contains two different integers A and B (1 ≤ A, B ≤ N) meaning that the link on page A points to page B.

Output

The first and only line of output should contain a single integer, the minimum number of additional links required to make the website K-reachable.

Sample Input

14 4
1 2
2 3
3 4
4 5
7 5
5 6
6 3
8 10
10 9
9 8
14 13
13 12
12 11
11 14

Sample Output

3

Hint

one possible solution is to add the links 1→7, 1→14 and 14→10

Source