#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1], t[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> t[i];
  int init = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i] == 1) {
      init += a[i];
      a[i] = 0;
    }
  }
  int maxv = 0, cur = 0;
  for (int i = 1; i <= k; i++) cur += a[i];
  maxv = max(maxv, cur);
  for (int i = 1; i < n - k + 1; i++) {
    cur -= a[i];
    cur += a[i + k];
    maxv = max(maxv, cur);
  }
  cout << maxv + init;
}
