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.
import sys

# taking input as string
input = lambda: sys.stdin.readline().rstrip("\r\n")
inp = lambda: list(map(int, sys.stdin.readline().rstrip("\r\n").split()))
mod = 10 ** 9 + 7;
Mod = 998244353;
INF = float('inf')
# ______________________________________________________________________________________________________
from math import *
from bisect import *
from heapq import *
from functools import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby

sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)  # this is must for dfs
MAX = 10 ** 5
# teaverse list in reverse order = for i in range(n-1, -1, -1)

############################### my code here ####################################
def solve():
    num = takeint()
    list_a = []
    list_b = []
    for _ in range(num):
        a, b = takeivar()
        list_a.append(a)
        if b != a:list_b.append(b)
        else:pass
    set_a = set(list_a)
    set_b = set(list_b)
    print(len(set_a.difference(set_b)))


def main():
    global tt

    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt", "r")
        sys.stdout = open("output.txt", "w")
    t = 1
    # t = takeint()
    # t = 1
    # for tt in range(1, t + 1):
    solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :", time.time() - start_time, "seconds")
        sys.stdout.close()


# ---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
# input the integer
def takeint():
    return (int(sys.stdin.readline().rstrip("\r\n")))


# input the string
def takestr():
    return (sys.stdin.readline().rstrip("\r\n"))


# input int array
def takeiarr():
    return (list(map(int, sys.stdin.readline().rstrip("\r\n").split())))


# input string array
def takesarr():
    return (list(map(str, sys.stdin.readline().rstrip("\r\n").split())))


# innut values for the diffrent variables
def takeivar():
    return (map(int, sys.stdin.readline().rstrip("\r\n").split()))


def takesvar():
    return (map(str, sys.stdin.readline().rstrip("\r\n").split()))


# ------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#


def ispalindrome(s):
    return s == s[::-1]


def invert(bit_s):
    # convert binary string
    # into integer
    temp = int(bit_s, 2)

    # applying Ex-or operator
    # b/w 10 and 31
    inverse_s = temp ^ (2 ** (len(bit_s) + 1) - 1)

    # convert the integer result
    # into binary result and then
    # slicing of the '0b1'
    # binary indicator
    rslt = bin(inverse_s)[3:]

    return str(rslt)


def swap(a, b):
    a, b = b, a
    return a, b


def counter(a):
    # create a list of frequency of each element in a
    # [2,3,2,1] -> [1,2,1]

    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return (q)


def counter_elements(a):
    # dictionary of frequency of elements
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return (q)


def string_counter(a):
    # returns list of frequency of each alphabet in given string
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return (q)


def factorial(n):
    # for very large numbers
    dp = [1] * (n + 1)

    for i in range(1, n + 1):
        dp[i] = dp[i - 1] * i
    return dp[n]

def isSubSequence(string1, string2, m, n):
       # Base Cases
    if m == 0:
           return True
    if n == 0:
           return False

        # If last characters of two
        # strings are matching
    if string1[m - 1] == string2[n - 1]:
           return isSubSequence(string1, string2, m - 1, n - 1)

        # If last characters are not matching
    return isSubSequence(string1, string2, m, n - 1)


def factors(n):
    q = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return (list(sorted(list(set(q)))))


def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return (list(sorted(q)))


def transpose(a):
    n, m = len(a), len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m):
        for j in range(n):
            b[i][j] = a[j][i]
    return (b)


def power_two(x):
    # returns true if x is a power of 2
    return (x and (not (x & (x - 1))))


def ceil(a, b):
    return -(-a // b)


def seive(n):
    # seive of eratosthenes
    # returns list of all prime numbers <= n

    a = [1]
    prime = [True for i in range(n + 1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p ** 2, n + 1, p):
                prime[i] = False
        p = p + 1
    for p in range(2, n + 1):
        if prime[p]:
            a.append(p)
    return (a)


def isprime(n):
    if (n > 2 and not n % 2) or n == 1:
        return False

    for i in range(3, int(n ** 0.5 + 1), 2):
        if not n % i:
            return False

    return True

# binary exponentiation
def binexp(a, b):
    if b == 0:
        return 1
    ans = binexp(a, b//2)
    if(b%2):
        return ans*ans*a
    else:
        return ans * ans

def most_frequent(nums):
    # most frequent element in a list
    return max(set(nums), key = nums.count)


def binary_search(nums, target):
    # nums must be already sorted
    low, high = 0, len(nums) - 1

    # returns -1 if element not found
    while low <= high:
        mid = (low + high) // 2
        if nums[mid] == target:return mid + 1
        if nums[mid] > target:high = mid - 1
        else:low = mid + 1
    return -1

def lcm(numbers):
    # list of numbers whose lcm is to be found
    return reduce((lambda x, y: int(x * y / gcd(x, y))), numbers)

def gcd(a, b):
    while(b): a, b = b, a % b
    return a
# -----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline

main()