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