#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, m, k;
const long long N = 2e5 + 7;
long long a[N];
string s;
long long fans = 0;
vector<long long> adj[N];
vector<long long> d(N, 0), vis(N, 0);
long long dfs(long long u) {
  vis[u] = 1;
  long long m1 = 0, m2 = 0;
  for (long long x : adj[u]) {
    if (!vis[x]) {
      long long f = 1 + dfs(x);
      if (f > m1)
        m2 = m1, m1 = f;
      else if (f > m2)
        m2 = f;
    }
  }
  fans = max(fans, m1 + m2);
  return m1;
}
void solve() {
  cin >> n >> m;
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  cout << fans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(12) << fixed;
  long long tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
