#include <stdio.h>
#include <algorithm>
#define NMAX 800001

using namespace std;

int N, i, A[NMAX], L, Nr, V[NMAX], *p;

int main()
{
	freopen("echilibru.in", "r", stdin);
	freopen("echilibru.out", "w", stdout);
	
	scanf("%d %d", &N, &L);
	Nr = 0;
	
	for( i=0; i<N; i++ ) scanf("%d", &A[i]);
	for( i=0; i<2*L+1; i++ )
		V[i] = A[i];
	
	sort( V, V+2*L+1 );
	p = lower_bound( V, V+2*L+1, A[L] );
	if( p-V == L ) ++Nr;
	
	for( i=2*L+1; i<N; i++ )
	{		
		p = lower_bound( V, V+2*L+1, A[i-2*L-1] );
		V[(int)(p-V)] = A[i];
		
		sort( V, V+2*L+1 );
		
		p = lower_bound( V, V+2*L+1, A[i-L] );
		if( p-V == L ) ++Nr;
	}
	
	printf("%d\n", Nr);
	
	return 0;
}
