N,K,*a=`dd`.split.map &:to_i r=0 N.times{(N-K).times{|i|a[i]>a[i+K]&&(a[i],a[i+K]=a[i+K],a[i];r+=1)}} p (0..N-2).all?{|i|a[i]