#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0, sum = 0;
  cin >> n;
  multiset<int> ms;
  for (int a = 0; a < n; a++) {
    int v = 0, s = 0;
    cin >> v >> s;
    ms.insert(v);
    ms.insert(s);
  }
  for (auto i = ms.begin(); i != ms.end(); i++)
    if (ms.count(*i) == 1) sum++;
  cout << sum;
}
