N, M = map(int, input().split()) A = list(map(int, input().split())) ans = N - M for i in range(M - 1) : n = A[i + 1] - A[i] - 1 while n > 1 and n & 1 : ans -= 1 n >>= 1 print(ans)