#include <bits/stdc++.h>
using namespace std;
int res = 0;
vector<int> way[100005];
int dp[2][100005];
int spe[100005];
int findmax(int x, int prev) {
  if (dp[0][x] != -1) return dp[0][x];
  dp[0][x] = dp[0][prev] + 1;
  int dp0er = prev;
  for (int i = 0; i < way[x].size(); i++) {
    if (way[x][i] == prev) continue;
    int d = findmax(way[x][i], x);
    d++;
    if (d >= dp[0][x]) {
      int temp = dp[0][x];
      dp[0][x] = d;
      dp[1][x] = temp;
      dp0er = way[x][i];
    } else if (d >= dp[1][x]) {
      dp[1][x] = d;
    }
  }
  if (dp[0][x] + dp[1][x] > res) res = dp[0][x] + dp[1][x];
  if (dp0er == prev) return dp[1][x];
  return dp[0][x];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) dp[0][i] = -1;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    way[u].push_back(v);
    way[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (way[i].size() == 1) {
      findmax(i, 0);
      break;
    }
  printf("%d", res);
  return 0;
}
