#include <bits/stdc++.h>
using namespace std;
long long n, m, i;
long long vis[100005], mx = -1, d[100005], dx[100005], vis2[100005];
vector<long long> v[100005];
void dfs(long long i, long long dis) {
  vis[i]++;
  d[i] = dis;
  for (auto it = v[i].begin(); it != v[i].end(); it++) {
    if (!vis[*it]) dfs(*it, dis + 1);
  }
}
void dfs2(long long i, long long dis) {
  vis2[i]++;
  dx[i] = dis;
  for (auto it = v[i].begin(); it != v[i].end(); it++) {
    if (!vis2[*it]) dfs2(*it, dis + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  long long flag = 0, xy;
  cin >> n >> m;
  if (m != n - 1) {
    cout << "no";
    return 0;
  }
  for (i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  long long pos = 0, pos2 = 0;
  for (i = 1; i <= n; i++) {
    if (d[i] > mx) {
      pos = i;
      mx = d[i];
    }
  }
  dfs2(pos, 0);
  for (i = 1; i <= n; i++) mx = max(mx, dx[i]);
  cout << mx;
}
