#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long int inf = 1e18;
vector<long long int> dp(N);
vector<long long int> a[N], vis(N);
long long int ans = 0;
void dfs(long long int u, long long int p, long long int d) {
  dp[u] = d;
  for (auto v : a[u]) {
    if (v != p) dfs(v, u, d + 1);
  }
}
void solve() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  dfs(1, -1, 0);
  long long int u = max_element(dp.begin(), dp.end()) - dp.begin();
  dfs(u, -1, 0);
  cout << *max_element(dp.begin(), dp.end());
}
void debug(long long int tt) {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
