#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> p[maxn];
int ans, f;
void dfs(int start, int finish, int s) {
  if (s > ans) {
    ans = s;
    f = start;
  }
  int i;
  for (i = 0; i < (int)p[start].size(); i++) {
    int to = p[start][i];
    if (to != finish) {
      dfs(to, start, s + 1);
    }
  }
}
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) p[i].clear();
  for (i = 1; i <= m; i++) {
    int start, finish;
    scanf("%d%d", &start, &finish);
    p[start].push_back(finish);
    p[finish].push_back(start);
  }
  ans = 0;
  dfs(1, 0, 0);
  ans = 0;
  dfs(f, 0, 0);
  printf("%d\n", ans);
}
