#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int f[maxn], g[maxn], longest[maxn];
vector<int> son[maxn], w[maxn];
int dfs(int root, int pre) {
  int i, j;
  int est = 0, esti = -1, er = 0;
  if (f[root] != -1) return f[root];
  if (son[root].empty()) return f[root] = 0;
  for (i = 0; i < son[root].size(); i++) {
    if (pre != son[root][i]) {
      if (dfs(son[root][i], root) + w[root][i] > est) {
        est = f[son[root][i]] + w[root][i];
        esti = i;
      }
    }
  }
  longest[root] = esti;
  for (i = 0; i < son[root].size(); i++) {
    if (pre != son[root][i]) {
      if (f[son[root][i]] + w[root][i] > er && i != longest[root]) {
        er = f[son[root][i]] + w[root][i];
      }
    }
  }
  g[root] = er;
  return f[root] = est;
}
void Init(int n) {
  int i;
  for (i = 0; i <= n; i++) {
    f[i] = g[i] = longest[i] = -1;
    son[i].clear();
    w[i].clear();
  }
}
int main() {
  int i, j, k, n, m, ans;
  int x1, x2, l;
  char opt;
  while (~scanf("%d%d", &n, &m)) {
    Init(n);
    for (i = 0; i < m; i++) {
      scanf("%d%d", &x1, &x2);
      son[x1].push_back(x2);
      w[x1].push_back(1);
      son[x2].push_back(x1);
      w[x2].push_back(1);
    }
    for (i = 1; i <= n; i++) {
      if (f[i] == -1) {
        f[i] = dfs(i, -1);
      }
    }
    ans = 0;
    for (i = 1; i <= n; i++) {
      ans = max(ans, f[i] + g[i]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
