n, m = map(int, input().split()) alst = list(map(int, input().split())) cnt = 0 tot = 0 for a in alst: if a % 2 == 1: cnt += 1 tot += a else: if cnt >= m: print(tot) cnt = 0 tot = 0 if cnt >= m: print(tot)