#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 1;
vector<long long> adj[N];
long long n, m, u, v, w, k;
long long ans = 0;
long long vis[N];
long long c = 0;
long long mul(long long i, long long j) {
  long long res = (i * j) % mod;
  return res;
}
long long pow(long long i, long long j) {
  long long res = 1;
  while (j) {
    if (j & 1) {
      res = mul(res, i);
    }
    i = mul(i, i);
    j /= 2;
  }
  return res;
}
long long dfs(long long u, long long par, long long cur = 0) {
  vector<long long> mx = {0, 0};
  for (long long v : adj[u]) {
    if (v != par) {
      long long val = dfs(v, u, cur + 1) + 1;
      if (val > mx[0]) {
        mx[0] = val;
        sort(mx.begin(), mx.end());
      }
    }
  }
  ans = max(ans, mx[0] + mx[1]);
  return mx[1];
}
void addEdge(long long i, long long j) {
  adj[i].push_back(j);
  adj[j].push_back(i);
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> u >> v;
    addEdge(u, v);
  }
  dfs(1, 0);
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  cout << "\n";
  ;
  return 0;
}
