#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > g;
vector<bool> used;
long long d = 0, c, ans, p;
void dfs(long long v, long long d) {
  if (used[v]) return;
  used[v] = 1;
  if (d > ans) {
    ans = d;
    c = v;
  }
  for (long long i = 0; i < g[v].size(); i++) {
    p = v;
    dfs(g[v][i], d + 1);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  g.resize(n);
  used.resize(n);
  long long a, b;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  if (m != n - 1) {
    cout << "no";
    return 0;
  }
  dfs(0, 0);
  used.assign(n, 0);
  dfs(c, 0);
  cout << ans;
  return 0;
}
