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*<sub class="lower-index">*i*</sub>, besides, you can use it to open other bottles of brand *b*<sub class="lower-index">*i*</sub>. 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*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> ≤ 1000) — the description of the *i*-th bottle.
n = int(input())
bottles,openings = {},{}
for x in range(n):
    b1,b2 = map(int,input().split(" "))
    if b2 not in openings: 
        openings[b2] = [b1]
    else: openings[b2].append(b1)
    if b1 not in bottles:
        bottles[b1] = 1
    else: bottles[b1] += 1
for curr_bottle in bottles:
    if curr_bottle not in openings: continue     # there is no other brand which can open this one
    for op in openings[curr_bottle]:
        if op == curr_bottle and bottles[op] > 1:
            n -= bottles[curr_bottle]
            break
        elif op != curr_bottle:
            n -= bottles[curr_bottle]
            break
print(n)

'''

We suppose that ai brand can only open one bi brand
:
3
2 828
4 392
4 903

map1 = {curr_bottle: [bottles which can open this current one]}
map2 = {bottle : amount}

then: iterate over map2: and on every signle bottle iterate 
over bottles which can open this current one until they open if it's possible.
if we're gonna be checking same brands opening, amont of bottles should be > 1,
otherwise it's impossible to open them, because one bottle cannot open itself.
If they are not the same, since we can open something else regardles it's opened or not
we are just substructing n -= bottles to open.

1 1
3 1 
2 3
2 3
2 3


2 2
2 2
2 2
2 2
3 2

graph?
'''