#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 5;
const int INF = 1 << 30;
int n, res;
int v[1 + NMAX];
int l[1 + NMAX];
int r[1 + NMAX];
int vis[1 + NMAX];
map<int, int> m;
void dfs(int node, int from, int to) {
  if (node == -1 || to < from) return;
  if (from <= v[node] && v[node] <= to) res += m[v[node]];
  dfs(l[node], from, min(v[node] - 1, to));
  dfs(r[node], max(v[node] + 1, from), to);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i] >> l[i] >> r[i];
    m[v[i]]++;
    vis[l[i]] = vis[r[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) dfs(i, 0, INF);
  cout << n - res << '\n';
  return 0;
}
