from collections import deque
n, k = map(int, input().split())
k = min(k, n - 1)
k += 1
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b = b + b[:k]
ans = 0
dq = deque()
for i in range(k):
while dq and b[dq[-1]] >= b[i]:
dq.pop()
dq.append(i)
for i in range(n):
ans += a[i] * b[dq[0]]
while dq and b[dq[-1]] >= b[i + k]:
dq.pop()
dq.append(i + k)
if dq and dq[0] <= i:
dq.popleft()
print(ans)