#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, inf = 1e9 + 10, MOD = 1e9 + 7, Sq = 708;
const long long INF = 1e18 + 10;
vector<int> g[maxn];
int dp1[maxn], dp2[maxn];
void dfs(int u, int p) {
  for (int v : g[u])
    if (v != p) {
      dfs(v, u);
      if (dp1[v] + 1 > dp1[u])
        dp2[u] = dp1[u], dp1[u] = dp1[v] + 1;
      else if (dp1[v] + 1 > dp2[u])
        dp2[u] = dp1[v] + 1;
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, 0);
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp1[i] + dp2[i]);
  cout << ans;
  return 0;
}
