#robot N,K=(int(i) for i in input().split()) a=[int(i) for i in input().split()] b=a.sort() i=0 C=0 while i=0: j=i while j=0 and b[j]!=a[i]: j+=K C+=1 if j>=N: C=-1 i+=1 print(C)