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

int n, m, res;

int a[32][2];
int used[32];

void dfs(int v, int d, int &res)
{
	int t, v2;
	if (d > res) res = d;
	for (int i = 0; i < m; i++)
		if (!used[i] && (a[i][0] == v || a[i][1] == v))
		{
			if (a[i][0] == v) v2 = a[i][1];
				else v2 = a[i][0];
			used[i] = 1;
			dfs(v2, d + 1, res);
			used[i] = 0;
		}
}

void solve()
{
	int t; res = 0;
	for (int i = 0; i < n; i++)
	{
		t = 0;
		dfs(i, 0, t);
		if (t > res) res = t;
	}
}

int main()
{
	while (scanf("%d%d", &n, &m) && n)
	{
		for (int i = 0; i < m; i++)
			scanf("%d%d", &a[i][0], &a[i][1]);
		solve();
		printf("%d\n", res);
	}
	return 0;
}

