#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long mapath = -1, pointt = 1;
long long D = -1;
vector<long long> tr[100009];
void dfs(long long u, long long f, long long sd) {
  if (mapath < sd) {
    mapath = sd;
    pointt = u;
  }
  for (auto v : tr[u])
    if (v != f && v != u) {
      dfs(v, u, sd + 1);
    }
}
void dfss(long long u, long long f, long long sd) {
  D = max(D, sd);
  for (auto v : tr[u])
    if (v != f && v != u) {
      dfss(v, u, sd + 1);
    }
}
signed main() {
  scanf("%lld%lld", &n, &m);
  long long a = 0, b = 0;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &a, &b);
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  dfs(1, -1, 0);
  dfss(pointt, -1, 0);
  printf("%lld\n", D);
  return 0;
}
