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