#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 17, N = 5e3 + 17, MOD = 1e9 + 7, Mod = 1e9 + 6;
long long n, m, x, y, ans, cnt, d[maxN], maxi, point;
vector<long long> a[maxN];
bool v[maxN];
void dfs(long long s, long long par) {
  v[s] = true;
  cnt++;
  if (par) d[s] = d[par] + 1;
  if (d[s] > point) point = d[s], maxi = s;
  for (long long i = 0; i < a[s].size(); i++) {
    if (!v[a[s][i]]) dfs(a[s][i], s);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++)
    cin >> x >> y, a[x].push_back(y), a[y].push_back(x);
  dfs(1, 0);
  point = 0;
  for (long long i = 1; i <= n; i++) d[i] = 0, v[i] = false;
  dfs(maxi, 0);
  return cout << point << "\n", 0;
}
