#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int MAXN = 1e5 + 5;
const long long MOD = 1e9 + 7;
int n, k;
int a[MAXN];
int t[MAXN];
int num[MAXN];
long long qz[MAXN];
long long l[MAXN];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
  }
  for (int i = 1; i <= n; i++) qz[i] = qz[i - 1] + a[i];
  for (int i = 1; i <= n; i++) l[i] = l[i - 1] + a[i] * t[i];
  long long ans = 0;
  for (int i = 1; i <= n - k + 1; i++)
    ans =
        max(ans, l[i - 1] + qz[i + k - 1] - qz[i - 1] + (l[n] - l[i + k - 1]));
  cout << ans << endl;
  return 0;
}
