301649: CF315A. Sereja and Bottles

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Sereja and Bottles

题意翻译

Sereja有n个瓶子,第i个瓶子是$a_{i}$类的,用这个瓶子可以打开$b_{i}$类的瓶子,无论瓶子有没有打开,它都可以用来打开其他瓶子,求有几个瓶子无法打开

题目描述

Sereja and his friends went to a picnic. The guys had $ n $ soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles. Sereja knows that the $ i $ -th bottle is from brand $ a_{i} $ , besides, you can use it to open other bottles of brand $ b_{i} $ . You can use one bottle to open multiple other bottles. Sereja can open bottle with opened bottle or closed bottle. Knowing this, Sereja wants to find out the number of bottles they've got that they won't be able to open in any way. Help him and find this number.

输入输出格式

输入格式


The first line contains integer $ n $ $ (1<=n<=100) $ — the number of bottles. The next $ n $ lines contain the bottles' description. The $ i $ -th line contains two integers $ a_{i},b_{i} $ $ (1<=a_{i},b_{i}<=1000) $ — the description of the $ i $ -th bottle.

输出格式


In a single line print a single integer — the answer to the problem.

输入输出样例

输入样例 #1

4
1 1
2 2
3 3
4 4

输出样例 #1

4

输入样例 #2

4
1 2
2 3
3 4
4 1

输出样例 #2

0

Input

题意翻译

Sereja有n个瓶子,第i个瓶子是$a_{i}$类的,用这个瓶子可以打开$b_{i}$类的瓶子,无论瓶子有没有打开,它都可以用来打开其他瓶子,求有几个瓶子无法打开

加入题单

算法标签: