#include <bits/stdc++.h>
using namespace std;
int dfs(unordered_map<int, vector<int>> &m, int start, int *visited, int &val) {
  visited[start] = 1;
  int max = 0;
  int maxi = 0;
  for (int i = 0; i < m[start].size(); i++) {
    if (visited[m[start][i]] == 0) {
      int x = 1 + dfs(m, m[start][i], visited, val);
      if (x >= max) {
        maxi = max;
        max = x;
      } else if (x >= maxi)
        maxi = x;
    }
  }
  if (max + maxi > val) val = max + maxi;
  return max;
}
int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<int, vector<int>> m1;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    m1[x].push_back(y);
    m1[y].push_back(x);
  }
  int *visited = new int[n + 1]();
  int val = 0;
  int ans = dfs(m1, 1, visited, val);
  cout << val;
}
