#include <stdio.h>

//STL 사용할 때
#include <queue>
#include <algorithm>
using namespace std;

int G[101][101];
int v[101];
int n,e;

int main()
{
    int i,j,k;
    int pshort[101];
    int max_pshort=-987654321;
    queue<int> que;

    scanf("%d",&n);
    scanf("%d",&e);
    for(k=0; k<e; k++)
    {
        scanf("%d %d",&i,&j);
        G[i][j]=1;
        G[j][i]=1;
    }

    que.push(1);
    v[1]=1;
    while(!que.empty())
    {
        i=que.front();
        que.pop();
        for(j=1; j<=n; j++)
        {
            if(G[i][j]==1 && v[j]==0)
            {
                que.push(j);
                v[j]=1;
                pshort[j]=pshort[i]+1;
                if(max_pshort < pshort[j]) max_pshort=pshort[j];
            }
        }
    }
    printf("%d",max_pshort);
    return 0;
}