#include <bits/stdc++.h>
using namespace std;
const int M = 300005;
int read() {
  int x = 0, f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') f = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int n, m, tot, cnt, Index, f[M], dfn[M], low[M], in[M];
int col[M], ans, mx[M][2];
vector<int> g[M];
stack<int> s;
struct edge {
  int v, next;
} e[2 * M];
void dfs(int u, int p) {
  dfn[u] = low[u] = ++Index;
  in[u] = 1;
  s.push(u);
  for (int i = f[u]; i; i = e[i].next) {
    int v = e[i].v;
    if (v == p) continue;
    if (!dfn[v]) {
      dfs(v, u);
      low[u] = min(low[u], low[v]);
    } else if (in[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    int v = 0;
    cnt++;
    do {
      v = s.top();
      s.pop();
      col[v] = cnt;
      in[v] = 0;
    } while (u != v);
  }
}
void dfs1(int u) {
  in[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (in[v]) continue;
    dfs1(v);
    if (mx[u][0] < mx[v][0] + 1) {
      mx[u][1] = mx[u][0];
      mx[u][0] = mx[v][0] + 1;
    } else if (mx[u][1] < mx[v][0] + 1)
      mx[u][1] = mx[v][0] + 1;
  }
  ans = max(ans, mx[u][0] + mx[u][1]);
}
signed main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    e[++tot] = edge{v, f[u]}, f[u] = tot;
    e[++tot] = edge{u, f[v]}, f[v] = tot;
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++) {
    int u = col[i];
    for (int j = f[i]; j; j = e[j].next) {
      int v = col[e[j].v];
      if (u == v) continue;
      g[u].push_back(v);
    }
  }
  for (int i = 1; i <= cnt; i++)
    if (!in[i]) dfs1(i);
  printf("%d\n", ans);
}
