def find_parent(parent, x):
if parent[x] != x:
parent[x] = find_parent(parent, parent[x])
return parent[x]
def union_parent(parent, a, b):
a = find_parent(parent, a)
b = find_parent(parent, b)
if a < b:
parent[b] = a
else:
parent[a] = b
d = int(input())
p = int(input())
parent = list(range(0, d + 1))
result = 0
for i in range(p):
data = find_parent(parent, int(input()))
if not data:
break
else:
union_parent(parent, data, data - 1)
result += 1
print(result)