long k;c,n,d[1<<18],u[1<<18];f(v){u[v]?c--:f(d[v],u[v]=++c);}main(i){for(scanf("%d%ld",&n,&k);~scanf("%d",d+i++););for(--i;--i;)!u[i]&&f(i);n=!puts(k