#include <bits/stdc++.h>
using namespace std;
void debug() {
  fflush(stdin);
  printf("Press any key to continue");
  getc(stdin);
  fflush(stdin);
}
int n, m;
vector<int> g[100005];
int length[100005];
int dia[100005];
void dfs(int u, int prev) {
  int max1 = -1, max2 = -1;
  for (int j = 0; j < g[u].size(); j++) {
    int v = g[u][j];
    if (v != prev) {
      dfs(v, u);
      length[u] = max(length[u], 1 + length[v]);
      if (length[v] > max1) {
        max2 = max1;
        max1 = length[v];
      } else if (length[v] > max2)
        max2 = length[v];
    }
  }
  dia[u] = 2 + max1 + max2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dia[i]);
  printf("%d\n", ans);
  return 0;
}
