#include<iostream>
using namespace std;
const int N = 1010;
int a[N], b[N], p[N], s[N];
int find(int x)
{
if(p[x] != x)p[x] = find(p[x]);
return p[x];
}
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++)a[i] = i;
for(int i = 1; i <= n; i ++)
{
cin >> b[i];
}
int ans = 0;
for(int i = 1; i <= n; i ++)p[i] = i, s[i] = 1;
for(int i = 1; i <= n; i ++)
{
int x = a[i], y = b[i];
if(find(x) != find(y) && y != 0)
{
s[find(y)] += s[find(x)];
p[find(x)] = find(y);
}
}
for(int i = 1; i <= n; i ++)
{
if(b[i] == 0){
int x = find(i);
ans += s[x];
}
}
cout << ans <<endl;
}