#include <bits/stdc++.h>
using namespace std;
bool p(bool h[],int n){
for(int i = 0;i < n;i++){
if(!h[i]){
return 0;
}
}
return 1;
}
int main(){
int n,m;
cin>>n>>m;
int a[n],b[n] = {},r = m,j = 1;
bool c[n] = {};
for(int i = 0;i < n;i++){
cin>>a[i];
}
while(!p(c,n)){
for(int i = 0;i < m;i++){
b[i];
}
for(int i = 0;i < m;i){
if(a[i] == b[i]){
c[i] = 1;
if(r != n){
swap(a[i],a[r]);
swap(b[i],b[r]);
swap(c[i],c[r]);
r++;
}
}
}
j++;
}
cout<<j-1<<endl;
return 0;
}