//Tudose Vlad Andrei
//O(N + M) - 100 de puncte
#include <cstdio>
#include <vector>
#define INPUT "dag.in"
#define OUTPUT "dag.out"
#define MAXN 100001
using namespace std;
int Deg[MAXN];
vector<int> G[MAXN], L[MAXN];

int main()
{
	int n, m, x, y, i, d, ans;

	freopen(INPUT, "r", stdin);
	freopen(OUTPUT, "w", stdout);

	scanf("%d%d", &n, &m);
	while(m--)
	{
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	for(i = 1; i <= n; ++i)
	{
		Deg[i] = G[i].size();
		L[Deg[i]].push_back(i);
	}

	ans = -1; d = 0;
	while(n > 0)
	{
		if(L[d].size() == 0)
		{
			++d;
			continue;
		}

		x = L[d].back();
		L[d].pop_back();

		if(Deg[x] == -1)
			continue;

		if(d > ans)
			ans = d;

		Deg[x] = -1; --n;
		for(i = 0; i < G[x].size(); ++i)
		{
			y = G[x][i];
			if(Deg[y] == -1)
				continue;
			L[--Deg[y]].push_back(y);
		}
		if(d > 0 && L[d - 1].size() > 0)
			--d;
	}

	printf("%d\n", ans);

	return 0;
}
