#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, st, de = 0;
vector<int> ve[100005];
void dfs(int now, int fa, int dep) {
  if (dep > de) {
    de = dep;
    st = now;
  }
  int len = ve[now].size();
  for (int i = 0; i < len; i++) {
    int to = ve[now][i];
    if (to != fa) dfs(to, now, dep + 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    ve[u].push_back(v);
    ve[v].push_back(u);
  }
  dfs(1, 0, 0);
  dfs(st, 0, 0);
  printf("%d\n", de);
  return 0;
}
