#include <bits/stdc++.h>
using namespace std;
void print(int dp[], int size) {
  for (int i = 0; i < size; i++) {
    cout << dp[i] << " ";
  }
  cout << endl;
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  int t[n + 1];
  a[0] = 0;
  t[0] = 0;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      sum += a[i];
    }
  }
  int ps[n + 1];
  ps[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i] == 0) {
      ps[i] = ps[i - 1] + a[i];
    } else {
      ps[i] = ps[i - 1];
    }
  }
  int dp[n + 1];
  dp[0] = 0;
  int maxi = INT_MIN;
  for (int i = 1; i <= n - k + 1; i++) {
    int l = i;
    int r = i + k - 1;
    maxi = max(maxi, ps[r] - ps[l - 1]);
  }
  cout << maxi + sum << endl;
}
