#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n), t(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  int answer = 0;
  int sub_ans = 0;
  vector<int> dp(n + 1);
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i] + (1 - t[i]) * a[i];
    sub_ans += t[i] * a[i];
  }
  for (int i = k; i <= n; i++) {
    answer = max(answer, sub_ans + dp[i] - dp[i - k]);
  }
  cout << answer << "\n";
  return 0;
}
