#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
long long arr[N], arr2[N] = {}, sum[N] = {}, suminf[N] = {};
int main() {
  ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  for (int j = 1; j <= n; ++j) cin >> arr2[j];
  for (int i = 1; i <= n; ++i) {
    suminf[i] += (suminf[i - 1] + arr[i]);
    if (arr2[i])
      sum[i] += (sum[i - 1] + arr[i]);
    else
      sum[i] += sum[i - 1];
  }
  long long ans = INT_MIN;
  for (int i = 1; i <= (n - m + 1); ++i) {
    int z = i + m - 1;
    if (z > n) z = n;
    ans = max(ans,
              ((sum[n] - sum[z]) + (suminf[z] - suminf[i - 1]) + sum[i - 1]));
  }
  cout << ans << "\n";
  return 0;
}
