#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<pair<T, T> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> theorems(n);
  for (int i = 0; i < n; ++i) cin >> theorems[i];
  vector<int> awake(n);
  int max_theorems = 0;
  for (int i = 0; i < n; ++i) {
    cin >> awake[i];
    if (awake[i]) {
      max_theorems += theorems[i];
    }
  }
  for (int i = 0; i < k; ++i) {
    if (awake[i] == 0) {
      max_theorems += theorems[i];
    }
  }
  int i = 0, j = k;
  int curr_theorems = max_theorems;
  while (j < n) {
    if (awake[i] == 0) {
      curr_theorems -= theorems[i];
    }
    if (awake[j] == 0) {
      curr_theorems += theorems[j];
    }
    max_theorems = max(max_theorems, curr_theorems);
    ++i;
    ++j;
  }
  cout << max_theorems << "\n";
  return 0;
}
