#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, st, de = 0;
vector<int> ve[100005];
int dp[100005][2];
void dfs(int now, int fa) {
  int max1 = 0, max2 = 0, len = ve[now].size();
  if (len == 1 && now != 1) {
    dp[now][0] = dp[now][1] = 0;
    return;
  }
  for (int i = 0; i < len; i++) {
    int to = ve[now][i];
    if (to != fa) {
      dfs(to, now);
      if (dp[to][0] + 1 > max1) {
        max2 = max1;
        max1 = dp[to][0] + 1;
      } else
        max2 = max(max2, dp[to][0] + 1);
    }
  }
  dp[now][0] = max1;
  dp[now][1] = max1 + max2;
  de = max(de, dp[now][1]);
}
int main() {
  scanf("%d%d", &n, &m);
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    ve[u].push_back(v);
    ve[v].push_back(u);
  }
  dfs(1, 0);
  printf("%d\n", de);
  return 0;
}
