#include <bits/stdc++.h>
using namespace std;
int a[101], b[101];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  int c = 0;
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if ((i != j) && (b[j] == a[i])) ok = false;
    }
    if (ok) c++;
  }
  cout << c << endl;
  return 0;
}
