#include <bits/stdc++.h>
using namespace std;
int n, x[1001], y[1001], ans;
bool open[1001];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == j) continue;
      if (x[i] == y[j]) x[i] = 0;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (x[i]) ++ans;
  cout << ans << endl;
  return 0;
}
