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