#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > v[100011];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j, l, r, q, k, kk, x, y, c, m, n, p;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> l >> r;
    v[l].push_back(make_pair(r, 1));
    v[r].push_back(make_pair(l, 1));
  }
  set<pair<long long int, long long int> > vikas;
  long long int dist[100011];
  for (i = 0; i < 100011; i++) {
    dist[i] = (long long int)1e18;
  }
  vikas.insert(make_pair(0, 1));
  dist[1] = 0;
  while (vikas.size()) {
    set<pair<long long int, long long int> >::iterator it = vikas.begin();
    long long int u = (*it).second;
    vikas.erase(it);
    vector<pair<long long int, long long int> >::iterator i;
    for (i = v[u].begin(); i != v[u].end(); i++) {
      long long int v = (*i).first;
      long long int cost = (*i).second;
      if (dist[v] > dist[u] + cost) {
        dist[v] = dist[u] + cost;
        vikas.insert(make_pair(dist[v], v));
      }
    }
  }
  long long int maxi = 0;
  long long int indx;
  for (i = 1; i <= n; i++) {
    if (dist[i] > maxi) {
      indx = i;
      maxi = dist[i];
    }
  }
  for (i = 0; i < 100011; i++) {
    dist[i] = (long long int)1e18;
  }
  vikas.erase(vikas.begin(), vikas.end());
  vikas.insert(make_pair(0, indx));
  dist[indx] = 0;
  while (vikas.size()) {
    set<pair<long long int, long long int> >::iterator it = vikas.begin();
    long long int u = (*it).second;
    vikas.erase(it);
    vector<pair<long long int, long long int> >::iterator i;
    for (i = v[u].begin(); i != v[u].end(); i++) {
      long long int v = (*i).first;
      long long int cost = (*i).second;
      if (dist[v] > dist[u] + cost) {
        dist[v] = dist[u] + cost;
        vikas.insert(make_pair(dist[v], v));
      }
    }
  }
  maxi = 0;
  for (i = 1; i <= n; i++) {
    maxi = max(maxi, dist[i]);
  }
  cout << maxi;
  return 0;
}
