#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100002];
pair<int, int> dfs(int u, int p) {
  int ans = 0, mx[] = {-1, -1, -1};
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    pair<int, int> k = dfs(v, u);
    ans = max(ans, k.first);
    mx[0] = k.second + 1;
    sort(mx, mx + 3);
  }
  for (int i = 0; i < 3; i++) mx[i] = max(mx[i], 0);
  ans = max(ans, mx[1] + mx[2]);
  return make_pair(ans, mx[2]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  printf("%d\n", dfs(1, -1).first);
}
