#include <bits/stdc++.h>
using namespace std;
const int N9 = 1e9 + 7;
const int N5 = 1e5 + 5;
const double PI = 3.1415926535;
long long n, k, val, Sum;
void solve() {
  cin >> n >> k;
  vector<long long> vsum1(n + 1), vsum2(n + 1), a(n + 1), t(n + 1);
  Sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    Sum += a[i];
    vsum1[i] = Sum;
  }
  Sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    if (t[i]) Sum += a[i];
    vsum2[i] = Sum;
  }
  long long Max = 0;
  for (int i = 1; i + k <= n + 1; i++) {
    val = vsum2[i - 1] + (vsum1[i + k - 1] - vsum1[i - 1]) +
          (vsum2[n] - vsum2[i + k - 1]);
    Max = max(Max, val);
  }
  cout << Max;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  return 0;
}
