/*
TASK:SCHOOL
LANG:c
*/

#include <stdio.h>

struct QUEUE_struct {
	int data[500];
	int length;
} queue_m;

void q_add (struct QUEUE_struct* qu, int item) {
	qu->data[qu->length++] = item;
}

int q_get (struct QUEUE_struct* qu) {
	int trt = qu->data[0];
	int i = 0;
	while (i < qu->length-1) {
		qu->data[i] = qu->data[i+1];
		i++;
	}
	qu->length--;
	return trt;
}

int n,m;

int links[500][500];

int students[500];

int unnotified_students (int student) {
	int friends = 0;
	queue_m.length = 1;
	queue_m.data[0] = student;
	int checked[500];
	int i = 0;
	while (i < n) {
		checked[i] = students[i];
		i++;
	}
	int cur_item;
	while (queue_m.length > 0) {
		cur_item = q_get(&queue_m);
		checked[cur_item-1] = 1;
		friends++;
		int i = 0;
		while (i < n) {
			if (links[cur_item-1][i] && !checked[i]) {
				q_add(&queue_m, i+1);
			}
			i++;
		}
	}
	return friends-1;
}
void notify_student (int student) {
	queue_m.length = 1;
	queue_m.data[0] = student;
	int cur_item;
	while (queue_m.length > 0) {
		cur_item = q_get(&queue_m);
		students[cur_item-1] = 1;
		int i = 0;
		while (i < n) {
			if (links[cur_item-1][i] && !students[i]) {
				q_add(&queue_m, i+1);
			}
			i++;
		}
	}
}

int all_notified () {
	int i = 0;
	while (i < n) {
		if (!students[i]) return 0;
		i++;
	}
	return 1;
}

int main () {
	scanf("%i %i", &n, &m);
	int i = 0;
	int k,l,j;
	while (i < n) {
		students[i++] = 0;
	}
	i = 0;
	while (i < n) {
		j = 0;
		while (j < n) {
			links[i][j] = 0;
			links[j][i] = 0;
			j++;
		}
		i++;
	}
	i = 0;
	while (i < m) {
		scanf("%i %i", &k, &l);
		links[k-1][l-1] = 1;
		links[l-1][k-1] = 1;
		i++;
	}
	//
	int came = 0;
	int max_unnot;
	int max_unnot_id;
	int unnot;
	while (!all_notified()) {
		i = 0;
		max_unnot = -1;
		while (i < n) {
			unnot = unnotified_students(i+1);
			if (unnot > max_unnot && !students[i]) {
				max_unnot = unnot;
				max_unnot_id = i+1;
			}
			i++;
		}
		//
		came++;
		notify_student(max_unnot_id);
	}
	printf("%i\n", came);
	return 0;
}
