#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
int inf = 1e9;
array<int, 1005> A, B;
int dp(int p, int n, int m) {
int sum = 0, ans = -inf;
for (int i = 1; i <= m; i++) {
if (i + p < 1 || i + p > n) continue;
sum += A[i + p] * B[i];
ans = max(sum, ans), sum = max(sum, 0);
}
return ans;
}
int main() {
int n, m, ans = -inf;
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> A[i];
for (int i = 1; i <= n; i++) cin >> B[i];
for (int i = 1 - m; i <= n; i++) ans = max(ans, dp(i, n, m));
for (int i = 1; i <= m >> 1; i++) swap(B[i], B[m - i + 1]);
for (int i = 1 - m; i <= n; i++) ans = max(ans, dp(i, n, m));
cout << ans << '\n';
return 0;
}