#include <stdio.h>
#include <string.h>

#define MAXN 800100
#define NORMAL 500003
#define MAXIM 1000010

int A[MAXN], B[MAXIM];
int Nr[MAXN], S[MAXIM];
int i,N,L,ans,val;
char St[MAXN*10];
int semn,x,poz;

inline void adaug(const int &x)
{
	int i;
	for (i=x; i<MAXIM; i+=B[i])
		S[i]+=val;
}

inline int sum(const int &x)
{
	int i, e = 0;
	for (i=x; i>0; i-=B[i])
		e += S[i];
	return e;
}

int main()
{
	freopen("echilibru.in","r",stdin);
	freopen("echilibru.out","w",stdout);
	
	scanf("%d %d\n",&N,&L);
	B[0] = 1;
	fgets(St, MAXN*10, stdin);
	poz = 0;
	for (i=1; i<=N; ++i){
		if (St[poz]=='-'){
			semn = -1;
			++poz;
		}
		else semn = 1;
		x = 0;
		while (St[poz]>='0' && St[poz]<='9'){
			x = x*10 + St[poz] -'0';
			++poz;
		}
		++poz;
		A[i] = semn*x + NORMAL;
	}
	
	for (i=1; i<MAXIM; ++i)
		if (i&1) B[i] = 1;
		else
			B[i] = B[i>>1] << 1;
		
	
	ans = 0;
	val = 1;
	for (i=1; i<=2*L+1; ++i)
		adaug(A[i]);
	for (i=L+1; i<=N-L; ++i){
		if (sum(A[i]-1) == L) 
			++ans;
		val = 1;
		if (i+L+1 <= N)
			adaug(A[i+L+1]);
		val = -1;
		adaug(A[i-L]);
	}

	
	printf("%d\n", ans);

	return 0;
}