#include<stdio.h>
int i,j,n,l,v[800001],m,mic,mare,count;
int main()
{
	freopen("echilibru.in","r",stdin);
	freopen("echilibru.out","w",stdout);
	scanf("%d%d",&n,&l);
	for(i=1;i<=n;i++)
		scanf("%d",&v[i]);
	for(i=l+1;i<=n-l;i++)
	{
		for(j=i-l;j<=i+l;j++)
		{
			if(j!=i)
			{
			if(v[j]<v[i])
				mic++;
			if(v[j]>=v[i])
				mare++;
			}
		}
		if(mare==mic)
			count++;
		mare=0;
		mic=0;
	}
	printf("%d",count);
	return 0;
}