#include <bits/stdc++.h>
using namespace std;
void cpSetup() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int32_t main() {
  cpSetup();
  long long n;
  cin >> n;
  pair<long long, long long> a[n];
  bool b[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    b[i] = false;
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long canBeOpened = a[i].second;
    for (long long j = 0; j < n; j++) {
      if (j != i and a[j].first == canBeOpened and b[j] == false) {
        res++;
        b[j] = true;
      }
    }
  }
  cout << abs(n - res) << endl;
  return 0;
}
