#include <bits/stdc++.h>
using namespace std;
long long mod(long long n) { return n % (long long)1000000007; }
vector<long long> adj[200005];
bool vis[200005];
long long c[200005];
long long s[200005];
bool cyc = 0;
long long el, cnt;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long dp[100005];
long long p[100005];
long long ans;
void dfs(long long u) {
  dp[u] = 0;
  vis[u] = true;
  for (auto i : adj[u]) {
    if (vis[i] == false) {
      dfs(i);
      ans = max(dp[i] + dp[u], ans);
      dp[u] = max(dp[i] + 1, dp[u]);
    }
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i < m + 1; i = i + 1) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(vis, false, sizeof(vis));
  dfs(1);
  cout << ans + 1;
}
