#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000 + 20, inf = 0x3f3f3f3f;
int f[Maxn], g[Maxn], n, m, ans;
vector<int> e[Maxn];
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
void dfs(int x, int fa) {
  int m1 = -1, m2 = -1;
  for (int i = 0; i < e[x].size(); ++i) {
    int y = e[x][i];
    if (y == fa) continue;
    dfs(y, x);
    int tmp = f[y] + 1;
    f[x] = max(f[x], tmp);
    if (tmp > m1)
      m2 = m1, m1 = tmp;
    else if (tmp > m2)
      m2 = tmp;
  }
  ans = max(max(ans, m1 + m2), max(m1, m2));
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) f[i] = i;
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    if (find(x) == find(y)) continue;
    e[x].push_back(y);
    e[y].push_back(x);
    f[find(x)] = find(y);
  }
  fill(f + 1, f + 1 + n, 0);
  dfs(1, 0);
  printf("%d\n", ans);
}
