#include <bits/stdc++.h>
using namespace std;
const int DIM = 1e5 + 1;
vector<int> adj[DIM];
bitset<DIM> vis;
int dist[DIM];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    adj[x].emplace_back(y);
    adj[y].emplace_back(x);
  }
  queue<int> q;
  q.push(1);
  int last = 1;
  vis[last] = true;
  while (!q.empty()) {
    int nod = q.front();
    q.pop();
    last = nod;
    for (auto i : adj[nod])
      if (vis[i] == false) {
        q.emplace(i);
        vis[i] = true;
      }
  }
  q.emplace(last);
  vis[last] = false;
  int ans = 1;
  dist[last] = 1;
  while (!q.empty()) {
    int nod = q.front();
    q.pop();
    ans = max(ans, dist[nod]);
    for (auto i : adj[nod])
      if (vis[i] == true) {
        vis[i] = false;
        q.emplace(i);
        dist[i] = dist[nod] + 1;
      }
  }
  cout << ans - 1 << '\n';
}
