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