#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vec;
bool vis[103];
int main() {
  int n, aux = 0, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    vec.push_back({a, b});
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (vec[i].second == vec[j].first and !vis[j]) {
        aux++;
        vis[j] = 1;
      }
    }
  }
  printf("%d", n - aux);
  return 0;
}
