#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ans = 0;
long long a[1000000], sl[1000000], p[1000000], pp[1000000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i], p[i] = a[i] + p[i - 1];
  for (i = 1; i <= n; i++) cin >> sl[i], pp[i] = a[i] * sl[i] + pp[i - 1];
  for (i = 1; i <= n; i++) {
    long long temp =
        p[i + k - 1] - p[i - 1] + pp[i - 1] + pp[n] - pp[i + k - 1];
    ans = max(ans, temp);
  }
  cout << ans;
}
