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