# April Sum of Odd def main(): N,M = map(int, input().split()) A = list(map(int, input().split())) tot = 0 cnt = 0 for a in A: if a % 2 == 1: cnt += 1 tot += a else: if cnt >= M: print(tot) tot = 0 cnt = 0 if tot != 0: print(tot) if __name__ == "__main__": main()