#include <bits/stdc++.h>
int map[100005][100], n, m, a, b, c, w[100005], ans, last;
void dfs(int cur, int pre, int len) {
  if (len > ans) {
    ans = len;
    last = cur;
  }
  for (int i = 0; i < w[cur]; i++) {
    int temp = map[cur][i];
    if (temp != pre) dfs(temp, cur, len + 1);
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(map, 0, sizeof(map));
    memset(w, 0, sizeof(w));
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &a, &b);
      map[a][w[a]] = b;
      map[b][w[b]] = a;
      w[a]++;
      w[b]++;
    }
    ans = 0;
    dfs(1, 0, 0);
    ans = 0;
    dfs(last, 0, 0);
    printf("%d\n", ans);
  }
}
