#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
const int INF = 1e9;
const double inf = 1e20;
const double eps = 1e-6;
struct bottle {
  int from, to;
  bool open;
} p[105];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i].from, &p[i].to);
    p[i].open = false;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (p[j].to == p[i].from) {
        p[i].open = true;
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!p[i].open) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
