#include <bits/stdc++.h>
using namespace std;
vector<int> f(100000, -1);
vector<int> g(100000, -1);
vector<vector<int>> adj;
void dfs(int v, int pv, int depth) {
  f[v] = 0;
  g[v] = 0;
  int lc = 0;
  for (int cv : adj[v]) {
    if (cv != pv) {
      dfs(cv, v, depth + 1);
      if (f[v] < f[cv] + 1) {
        lc = cv;
        f[v] = f[cv] + 1;
      }
    }
  }
  if (lc > 0) {
    for (int cv : adj[v]) {
      if (cv != pv && cv != lc) {
        g[v] = max(g[v], f[v] + f[cv] + 1);
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  adj.assign(n + 1, vector<int>());
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    if (f[i] < 0) dfs(i, i, 0);
  }
  int f_max = *max_element(f.begin(), f.end());
  int g_max = *max_element(g.begin(), g.end());
  printf("%d\n", max(f_max, g_max));
}
