x[1010],s,i,j; main(k){ for(scanf("%*d%d",&k);~scanf("%d",x+i);i++); for(;--i>0;x[i]x[j]?x[j-k]^=x[j]^=x[j-k]^=x[j],s++:0; s=!printf("%d",i|s); }