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