#include <bits/stdc++.h>   using namespace std;   vector<int> edge[100005];   int v[100005];   bool cycle = false;   int mx = -1, last;   void dfs(int u, int dis = 0) {     v[u] = 1;     if (dis > mx) {       mx = dis;       last = u;     }     for (int i = 0; i <= (int)((int)edge[u].size() - 1); i++) {       int first = edge[u][i];       if (!v[first]) dfs(first, dis + 1);     }   }   int main() {     int T, n, m, a, b;     scanf( %d , &n);     scanf( %d , &m);     for (int i = 1; i <= (int)(m); i++) {       scanf( %d%d , &a, &b);       edge[a].push_back(b);       edge[b].push_back(a);     }     dfs(1);     memset(v, 0, sizeof(v));     mx = -1;     dfs(last);     printf( %d , mx);     return 0;   }   