#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long k, n, maxi = 0;
  cin >> n >> k;
  vector<long long> v(n), w(n);
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> v[i];
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> w[i];
  vector<long long> dp(n + 1), dp1(n + 1);
  dp[0] = 0;
  dp1[0] = 0;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    dp1[i + 1] = dp1[i] + v[i];
    dp[i + 1] = dp[i] + v[i] * w[i];
  }
  long long temp, temp1;
  for (__typeof(n + 1) i = (k) - ((k) > (n + 1));
       i != (n + 1) - ((k) > (n + 1)); i += 1 - 2 * ((k) > (n + 1))) {
    temp = dp[i] - dp[i - k];
    temp1 = dp1[i] - dp1[i - k];
    if ((temp1 - temp) > maxi) maxi = temp1 - temp;
  }
  long long ans = dp[n] + maxi;
  cout << ans;
}
