// kaktuszgraf.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
using namespace std;
struct adat
{
int lat,tav;
vector<int>sz;
};
int n, a, b, i, maxi,bejart[1001][1001],m;
vector<adat>x;
void melysegi(int csp)
{
x[csp].lat = 1;
for (auto& e : x[csp].sz)
{
if (!x[e].lat)
{
bejart[csp][e] = bejart[e][csp] = 1;
x[e].tav = x[csp].tav + 1;
melysegi(e);
}
else
{
if (!bejart[csp][e])
{
if (maxi < abs(x[csp].tav - x[e].tav) + 1)
maxi = abs(x[csp].tav - x[e].tav) + 1;
}
else bejart[csp][e] = bejart[e][csp] = 1;
}
}
}
int main()
{
cin >> n >> m;
x.resize(n + 1);
for(i = 1; i <= m; ++i)
{
cin >> a >> b;
x[a].sz.push_back(b);
x[b].sz.push_back(a);
}
melysegi(1);
cout << maxi;
return 0;
}
/*
13 15
1 3
1 4
2 3
3 5
4 5
4 12
12 13
13 4
5 7
7 6
7 11
6 8
11 10
10 9
8 9
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file