#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> a[maxn];
int mx, lc;
void dfs(int x, int cnt, int pre) {
  if (cnt > mx) {
    mx = cnt;
    lc = x;
  }
  for (int i = 0; i < a[x].size(); i++) {
    if (a[x][i] != pre) {
      dfs(a[x][i], cnt + 1, x);
    }
  }
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    mx = 0;
    for (int i = 1; i <= n; i++) {
      a[i].clear();
    }
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      a[x].push_back(y);
      a[y].push_back(x);
    }
    dfs(1, 0, 0);
    dfs(lc, 0, 0);
    cout << mx << endl;
  }
  return 0;
}
