n,m=map(int,input().split()) a=list(map(int,input().split())) ans=0 odd =0 for i in a: if i%2 != 0: ans+=i odd+=1 else: if odd >= m: print(ans) ans=0 odd=0 if odd >= m: print(ans)