def Map(): return list(map(int,input().split())) N,M = Map() A = Map() B = Map() C = Map() AA = [0] for i in range(1,N): b = B[(i-1)%M] a = AA[-1] + b AA.append(a) for i in range(N): A[i] -= AA[i] d = {} for a in A: d[a] = 0 for i in range(N): d[A[i]] += C[i] S = sum(C) ans = S for a in A: res = S - d[a] ans = min(ans,res) print(ans)