#include <bits/stdc++.h>
using namespace std;
vector<int> a[100005];
queue<int> p;
int ji[100005], d[100005], ma = 0;
void dfs(int p, int k) {
  ji[p]++;
  d[p] = k;
  if (k > ma) ma = k;
  for (int i = 0; i < a[p].size(); i++) {
    if (ji[a[p][i]]) continue;
    dfs(a[p][i], k + 1);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs(1, 0);
  int v, mm = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i] > mm) mm = d[i], v = i;
  }
  memset(ji, 0, sizeof(ji));
  dfs(v, 0);
  printf("%d\n", ma);
  return 0;
}
