n, k = map(int, input().split()) lumbs = list(map(int, input().split())) prev = None count = 0 for i in range(len(lumbs)): if lumbs[i] == 0 and prev: count += 1 prev = None elif lumbs[i] == 1: prev = i if lumbs[i] == 1 and prev: count += 1 print(count)