#include <queue>
#include <vector>

const int MAXN = 100 * 1000 + 10;

bool mark[MAXN];
int vector<int> adj[MAXN];

void bfs(int v) {
    int far = 0;
    queue<int> q;
    queue<int> depth;
    
    mark[v] = 1;
    q.push(v);
    depth_v.push(0);
    
    while(q.size()) {
        v = q.front();
        far = depth.front();
        q.pop();
        depth.pop()
        
        for(int i = 0; i < adj[v].size(); i++) {
            int u = adj[v][i];
            
            if (mark[u] == 1)
                continue;
            
            mark[u] = 1;
            q.push(u);
            depth.push(far + 1);
        }
        
    }
    
    return far;
}

int find_diameter()
{
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(bfs(i), ans);
    return ans;
}