#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void smax(T &a, T b) {
  if (a < b) a = b;
}
int qf, qb, q[1111111];
int vst[111111], best[111111], res[111111];
vector<int> adj[111111], cadj[111111];
void make_tree(int u) {
  int i, v, deg;
  qf = qb = 0;
  q[qb++] = u;
  vst[u] = 1;
  while (qf < qb) {
    u = q[qf++], deg = cadj[u].size();
    for (i = 0; i < deg; i++) {
      v = cadj[u][i];
      if (vst[v]) continue;
      vst[v] = 1;
      adj[u].push_back(v);
      q[qb++] = v;
    }
  }
}
int main() {
  int N, M, u, v, i, j, mid, k, deg, a[4];
  scanf("%d%d", &N, &M);
  for (i = 0; i < M; i++) {
    scanf("%d%d", &u, &v);
    u--, v--;
    cadj[u].push_back(v);
    cadj[v].push_back(u);
  }
  make_tree(0);
  qf = qb = 0;
  q[qb++] = 0;
  while (qf < qb) {
    u = q[qf++], deg = adj[u].size();
    for (i = 0; i < deg; i++) {
      q[qb++] = adj[u][i];
    }
  }
  for (i = qb - 1; i >= 0; i--) {
    u = q[i], deg = adj[u].size();
    if (deg == 0) {
      best[u] = 0, res[u] = 0;
      continue;
    }
    best[u] = res[u] = mid = k = 0;
    for (j = 0; j < deg; j++) {
      v = adj[u][j];
      res[u] = max(res[u], res[v]);
      mid = max(mid, best[v]);
      a[k++] = res[v];
      if (k > 2) {
        if (a[0] < a[1]) swap(a[0], a[1]);
        if (a[0] < a[2]) swap(a[0], a[2]);
        if (a[1] < a[2]) swap(a[1], a[2]);
        k = 2;
      }
    }
    res[u]++;
    best[u] = max(res[u], best[u]);
    best[u] = max(mid, best[u]);
    if (k == 1) continue;
    best[u] = max(best[u], a[0] + a[1] + 2);
  }
  printf("%d\n", best[0]);
  return 0;
}
