#include <bits/stdc++.h>
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
bool isprime(long long n) {
  bool flag = true;
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, ans = 0;
  cin >> n >> k;
  vector<int> a, b, v;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a.push_back(k);
  }
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    b.push_back(k);
    if (k == 1) ans += a[i];
  }
  int sum = 0;
  for (int i = 0; i <= n; i++) {
    if (q.size() < k) {
      if (b[i] == 1)
        q.push(0);
      else {
        q.push(a[i]);
        sum += a[i];
      }
    } else {
      v.push_back(sum);
      int f = q.front();
      sum -= f;
      q.pop();
      if (b[i] == 1)
        q.push(0);
      else {
        q.push(a[i]);
        sum += a[i];
      }
    }
  }
  int max = *max_element(v.begin(), v.end());
  cout << ans + max;
  return 0;
}
