跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2424. Sereja and Bottles

    ID: 2430 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>枚举算法思想基础难度共享题库Codeforces英文题面题目来源题面语言

Sereja and Bottles

题目描述

A. Sereja and Bottles
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ai, besides, you can use it to open other bottles of brand bi. 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.

Input

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 ai,bi (1≤ai,bi≤1000) − the description of the i-th bottle.

Output

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

Examples
Input
4
1 1
2 2
3 3
4 4
Output
4
Input
4
1 2
2 3
3 4
4 1
Output
0

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2054 题。保留原作者与原赛事署名。