#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k, a, sum = 0;
  cin >> n >> k;
  long long int arr[n];
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0) {
      v.push_back(i);
    } else {
      sum = sum + arr[i];
    }
  }
  long long int i = 0, j = 0;
  long long int csum;
  long long int ans = 0;
  if (v.size() == 1 && k > 0) {
    ans = ans + arr[v[0]];
  }
  if (v.size() > 1) {
    csum = 0;
    while (i <= j && i < v.size() && j < v.size()) {
      if (v[j] - v[i] < k) {
        csum = csum + arr[v[j]];
        j++;
      } else {
        csum = csum - arr[v[i]];
        i++;
      }
      ans = max(ans, csum);
    }
  }
  cout << sum + ans;
}
