#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v, nxt;
} store[100005 * 2];
int head[100005], cnt = 0, fa[100005], val[100005], cur, max_len, p;
bool vis[100005];
void addedge(int u, int v) {
  store[cnt].nxt = head[u];
  head[u] = cnt;
  store[cnt].u = u;
  store[cnt++].v = v;
  store[cnt].nxt = head[v];
  head[v] = cnt;
  store[cnt].v = u;
  store[cnt++].u = v;
}
void dfs(int x, int pre, int step, int flag) {
  val[x] = step;
  if (val[x] > max_len) {
    max_len = val[x];
    p = x;
  }
  for (int i = head[x]; ~i; i = store[i].nxt) {
    if (store[i].v != pre) dfs(store[i].v, store[i].u, step + 1, flag);
  }
}
int main() {
  int n, m, q, a, b, tmp, op, ta, tb;
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
  cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    addedge(a, b);
  }
  max_len = 0;
  p = 0;
  dfs(1, -1, 0, 0);
  if (p != 0) dfs(p, -1, 0, 1);
  printf("%d\n", max_len);
  return 0;
}
