#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[111], b[111], open[111] = {0};
  int n, ans = 0;
  ;
  int i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != j && a[j] == b[i]) open[j] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    if (!open[i]) ans++;
  }
  cout << ans << "\n";
  return 0;
}
