#include <bits/stdc++.h>
using namespace std;
long long maxSum(vector<long long> arr, long long n, long long k) {
  long long res = 0;
  for (long long i = 0; i < k; i++) res += arr[i];
  long long curr_sum = res;
  for (long long i = k; i < n; i++) {
    curr_sum += arr[i] - arr[i - k];
    res = max(res, curr_sum);
  }
  return res;
}
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  vector<long long> type(n);
  long long ans = 0;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &type[i]);
    if (type[i]) {
      ans += arr[i];
      arr[i] = 0;
    }
  }
  long long maxx = maxSum(arr, n, k);
  printf("%d\n", ans + maxx);
}
