#include<iostream>
#include<stdio.h>
#include<vector> 
using namespace std;
int main(void)
{
    int n,k;
    cin>>n>>k;
    
    vector<int> score(n,0);
    
    vector<int> sleep(n,0);
    
    for(int i=0;i<n;i++)
        cin>>score[i];
    
    for(int i=0;i<n;i++)
        cin>>sleep[i];

    int res = 0;
    
    int extra = 0;
    
    int extra_max = 0;
    
    for(int i=0;i<k;i++)
    {
        if(!sleep[i])
            extra+=score[i];
    }
    
    if(sleep[0])
    res+=score[0];
    
    for(int i=1;i<n;i++)
    {
        if(sleep[i])
            res+=score[i];

        if(i+k-1<=n-1)
        {
            if(!sleep[i-1]) extra-=score[i-1];
            if(!sleep[i+k-1]) extra+=score[i+k-1];
        }
        
        extra_max = max(extra,extra_max);
    }
    
    cout<<extra_max+res<<endl;
    
    return 0;
}