#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
bool isOk[MAX];
int a[MAX], pre[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    cin >> isOk[i];
    pre[i] = pre[i - 1] + a[i] * isOk[i];
  }
  int sum = 0, ans_idx, ans_sum = sum;
  for (int i = 1; i <= n - k + 1; ++i) {
    if (i == 1) {
      for (int j = 1; j <= k; ++j) sum += a[j];
      ans_idx = 1;
      ans_sum = sum + pre[n] - pre[i + k - 1];
    } else {
      sum += a[i + k - 1];
      sum -= a[i - 1];
      if (sum + pre[i - 1] + pre[n] - pre[i + k - 1] > ans_sum) {
        ans_sum = sum + pre[i - 1] + pre[n] - pre[i + k - 1];
      }
    }
  }
  cout << ans_sum << endl;
}
