#include <bits/stdc++.h>
using namespace std;
int T;
void min_heapify(int arr[], int i) {
  int left = 2 * i;
  int right = 2 * i + 1;
  int minimum = i;
  if (arr[left] < arr[i]) minimum = left;
  if (arr[right] < arr[minimum]) minimum = right;
  if (minimum != i) {
    swap(arr[minimum], arr[i]);
    min_heapify(arr, minimum);
  }
}
void build_min_heap(int arr[], int p, int q) {}
void solution() {
  int n;
  cin >> n;
  pair<int, int> arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int flag = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (arr[j].second == arr[i].first) flag = 1;
    }
    if (flag == 0) cnt += 1;
  }
  cout << cnt << endl;
}
int main() {
  long long int t = 1;
  while (t--) {
    solution();
  }
}
