import std.stdio, std.algorithm, std.array, std.conv, std.typecons; alias Set = bool[3 * 10^^5]; void main() { readln; auto P = readln.split.to!(ulong[]); P = [0UL] ~ P; auto N = P.length-1; auto isnot_top = new bool[N+1]; foreach (p; P) { isnot_top[p] = true; } ulong ans; foreach (i; 1 .. N+1) if (!isnot_top[i]){ if (P[i] != 0 && P[P[i]] != 0) ans++; } writeln(ans); }