#include <bits/stdc++.h>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxi 1000010
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);
//ios_base::sync_with_stdio(false);
 //cin.tie(NULL);
//Code starts from here......

int main(){

    int n,k;
    cin>>n>>k;

    int a[n+3],b[n+3];
    int mini = INT_MAX;

    for(int i=0; i<n; i++){
        scanf("%d",&a[i]);
        mini = min(mini,a[i]);
        b[i]=a[i];
    }

    int i=0,j=n-1,pos=-1, ans1 = 0, ans2 = 0;

    while(i<n){

        int i1 = i;
        bool sign = false, sign1 =false;

        while(i<n && a[i] == mini ) i++;
        for(int k1=0; k1<k && i1<n; k1++) {

            if(a[i1] != mini ) sign = true;
            if(a[i1] == mini) sign1 = true;
            i1++;
        }
        
        if(sign){
            ans1++;
        }

       //cout<<"T  "<<i<<"  "<<sign<<endl;
        i1=i;

        if(sign1)i+=(k);
        else i+=(k-1);

        while(i<n && a[i] == mini) i++;

        int k2=0;

        if(sign && !sign1) k2=k-1;
        else k2=k;

        for(int k1=0; k1<k2 && i1<n; k1++) a[i1++]=mini;

    }

    while(j>=0){

        int j1 = j;
        bool sign = false, sign1 = false;
        while(j>=0 && b[j] == mini) j--;

        for(int k1=0;k1<k && j1>=0; k1++) {
            if(b[j1] != mini) sign = true;
            if(b[j1] == mini) sign1 = true;
            j1--;
        }

        if(sign){
             //   cout<<"F "<<"  "<<j<<endl;
            ans2++;
        }
        j1=j;
        if(!sign1)j-=(k-1);
        else j-=k;
        //cout<<"J  "<<j<<"  "<<ans2<<endl;

        while(j>=0 &&  b[j] == mini) j--;
        int k2 = 0;
        if(sign && !sign1) k2= k-1;
        else k2=k;

        for(int k1=0;k1<k2 && j1>=0; k1++) b[j1--]=mini;
    }

    //cout<<"A  "<<ans1<<" "<<ans2<<endl;

    cout<<min(ans1,ans2)<<endl;

    return 0;
}

/*

10 3 
2 2 2 1 2 1 1 1 2 1


*/

Measured memory_bytes: 1024