#include<stdlib.h>
#include<stdio.h>

typedef struct Queue {
	int date;
	struct Queue* next;
}Queue;
typedef struct{
	int length;
	struct Queue* front;
	struct Queue* rear;
}Head;
void Insert(Head* head, int date) {
	Queue* s = (Queue*)malloc(sizeof(Queue));
	s->date = date;
	if (head->front == NULL) {
		head->front = s;
		head->rear = s;
	}
	head->rear->next = s;
	head->rear= s;
	s->next = NULL;
	head->length++;
}
void Outqueue(Head* head) {
	Queue* p = head->front;
	head->front = p->next;
	head->length--;
	free(p);
}
int Query(Queue* front, int hit) {
	if (front == NULL) {
		return 0;
	}
	Queue* p = front;
	while (p->date != hit) {
		p = p->next;
		if (p == NULL) {
			return 0;
		}
	}
	return 1;
}
int main() {
	int M, N;
	scanf("%d %d", &M, &N);
	Head head;
	head.length = 0;
	head.front = NULL;
	head.rear = NULL;
	int num = 0;
	int res = 0;
	int count = 0;
	int i = N;
	while (i--) {
		scanf("%d", &num);
		res = Query(head.front, num);
		if (res) {
			count++;
		}
		else if (head.length < M) {
			Insert(&head, num);
		}
		else {
			Outqueue(&head);
			Insert(&head, num);
		}
	}
	printf("%d", N - count);
	return 0;
}