#include <bits/stdc++.h>
using namespace std;
int n, m, t;
vector<int> g[100001], used(100001), heigh(100001);
void DFS(int v = 1) {
  used[v] = 1;
  for (int x : g[v])
    if (used[x] == 0) {
      heigh[x] = heigh[v] + 1;
      DFS(x);
    }
}
int main() {
  cin >> n >> m;
  for (int x, y, i = 1; i <= m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  heigh[1] = 0;
  DFS();
  int mx = 0, ind;
  for (int i = 1; i <= n; i++)
    if (mx < heigh[i]) {
      mx = heigh[i];
      ind = i;
    }
  heigh[ind] = 0;
  for (int i = 1; i <= n; i++) used[i] = 0;
  DFS(ind);
  mx = 0;
  for (int i = 1; i <= n; i++)
    if (mx < heigh[i]) mx = heigh[i];
  cout << mx;
  return 0;
}
