#include <bits/stdc++.h>
using namespace std;
int n, m, dep[(int)(200005)], mx = -1, go = 0;
vector<int> ed[(int)(200005)], v;
void dfs(int cur, int back, int d) {
  if (d > mx) {
    mx = d;
    go = cur;
  }
  for (auto i : ed[cur])
    if (i != back) dfs(i, cur, d + 1);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  dfs(1, -1, 0);
  dfs(go, -1, 0);
  printf("%d\n", mx);
}
