#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, ans, s, len[maxn];
bool mark[maxn];
vector<int> v[maxn];
void Dfs(int cur, int pre, int len) {
  if (len > ans) {
    ans = len;
    s = cur;
  }
  for (auto to : v[cur]) {
    if (to != pre) {
      Dfs(to, cur, len + 1);
    }
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    for (auto &i : v) {
      i.clear();
    }
    for (int i = 0, a, b; i < m; ++i) {
      scanf("%d%d", &a, &b);
      v[a].push_back(b);
      v[b].push_back(a);
    }
    ans = 0;
    Dfs(1, 0, 0);
    ans = 0;
    Dfs(s, 0, 0);
    printf("%d\n", ans);
  }
  return 0;
}
