#include <bits/stdc++.h>
using namespace std;
const int z = 1e5 + 1;
vector<int> v[z];
int deep[z], f[z], k;
void dfs(int i) {
  f[i] = 1;
  if (deep[i] > deep[k]) k = i;
  for (int j = 0; j < v[i].size(); j++)
    if (!f[v[i][j]]) {
      deep[v[i][j]] = deep[i] + 1;
      dfs(v[i][j]);
    }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0);
  for (int i = 0; i < n; i++) deep[i] = f[i] = 0;
  dfs(k);
  cout << deep[k];
  return 0;
}
