#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
long long dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
long long expo(long long x, long long y) {
  long long res = 1;
  x = x % M;
  while (y > 0) {
    if (y & 1) res = (1ll * res * x) % M;
    y = y >> 1;
    x = (1ll * x * x) % M;
  }
  return res;
}
vector<vector<long long>> v(200005);
bool visited[200005];
long long dp[200005], mx, ini;
void dfs(long long n) {
  if (visited[n]) return;
  visited[n] = true;
  for (auto it : v[n]) {
    if (!visited[it]) {
      dp[it] = dp[n] + 1;
      if (dp[it] > mx) {
        mx = dp[it];
        ini = it;
      }
      dfs(it);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    while (m--) {
      long long x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    dfs(1);
    memset(dp, 0, sizeof dp);
    memset(visited, false, sizeof visited);
    mx = 0;
    dfs(ini);
    cout << mx;
  }
  return 0;
}
