#include <stdio.h>
#define N 100010
int formula[N];
int status[N];
int main(int argc, char *argv[])
{
	int m, k;
	scanf("%d%d", &m, &k);
	for(int i=0; i<m; ++i)
		scanf("%d", formula + i);
	for(int i=0; i<m; ++i)
		scanf("%d", status + i);
		
	int base = 0;
	int max = 0;
	int tmp = 0;
	for(int i=0; i<m; ++i)
	{
		if(status[i])
			base += formula[i];
		else
			tmp += formula[i];
		if(i>=k && status[i-k] == 0)
			tmp -= formula[i-k];	
		if(max < tmp)
			max = tmp;		
	}
	printf("%d\n", max + base);
	
	return 0;
}