#include <bits/stdc++.h>
using namespace std;
long long arr[500005];
long long beh[500005];
long long sum[500005];
long long sum2[500005];
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  for (long long i = 1; i <= n; i++) cin >> beh[i];
  for (long long i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + (beh[i] * arr[i]);
    sum2[i] = sum2[i - 1] + arr[i];
  }
  long long maxi = 0;
  for (long long i = k; i <= n; i++) {
    long long ans = (sum[i - k]) + (sum[n] - sum[i]) + sum2[i] - sum2[i - k];
    maxi = max(maxi, ans);
  }
  cout << maxi << endl;
}
