from collections import Counter, deque
M, N = map(int, input().split())
cnt = Counter() # 哈希表
queue = deque() # 双端队列
ans = 0 # 统计查询次数
for ch in input().split():
if cnt[ch] != 0: # 有当前字符
continue
ans += 1 # 查询
cnt[ch] += 1 # 计数
queue.append(ch) # 入队
if len(queue) > M:
cnt[queue.popleft()] -= 1
print(ans)