#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n][2];
  int arr2[n];
  for (int i = 0; i < n; i++) {
    arr[i][1] = 1;
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int y;
    cin >> y;
    arr[i][0] = x;
    arr2[i] = y;
  }
  for (int i = 0; i < n; i++) {
    int h = arr2[i];
    for (int j = 0; j < n; j++) {
      if (h == arr[j][0] && j != i) {
        arr[j][1] = 0;
      }
    }
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i][1] == 1) {
      count++;
    }
  }
  cout << count;
  return 0;
}
