#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int N = 100005;
int n, m;
vector<int> graph[N];
int dp[3][N];
void dfs(int s, vector<bool> &visited) {
  visited[s] = 1;
  dp[1][s] = dp[2][s] = 0;
  for (int v : graph[s]) {
    if (visited[v]) continue;
    dfs(v, visited);
    if (dp[1][v] + 1 >= dp[1][s]) {
      dp[2][s] = dp[1][s];
      dp[1][s] = dp[1][v] + 1;
    } else if (dp[1][v] + 1 >= dp[2][s]) {
      dp[2][s] = dp[1][v] + 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  vector<bool> visited(n + 1, 0);
  dfs(1, visited);
  int maxN = 0;
  for (int i = 1; i <= n; ++i) {
    maxN = max(maxN, dp[1][i] + dp[2][i]);
  }
  cout << maxN;
  return 0;
}
