#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> G[maxn];
int ans, last;
void dfs(int cur, int pre, int len) {
  if (len > ans) {
    ans = len;
    last = cur;
  }
  for (int i = 0; i < G[cur].size(); i++) {
    int to = G[cur][i];
    if (to != pre) dfs(to, cur, len + 1);
  }
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < maxn; i++) G[i].clear();
    for (int i = 0, x, y; i < m; i++) {
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    ans = 0;
    dfs(1, 0, 0);
    ans = 0;
    dfs(last, 0, 0);
    cout << ans << "\n";
  }
  return 0;
}
