#include <bits/stdc++.h>
using namespace std;
vector<int> A[100005];
bool visited[100005];
int l = 0, r = 0;
int V = 0;
void dfs(int v) {
  visited[v] = true;
  l++;
  if (l > r) {
    r = l;
    V = v;
  }
  for (vector<int>::iterator it = A[v].begin(); it != A[v].end(); it++) {
    if (visited[*it] == false) {
      dfs(*it);
    }
  }
  l--;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  dfs(1);
  l = 0;
  r = 0;
  for (int i = 0; i <= n; i++) {
    visited[i] = false;
  }
  dfs(V);
  cout << r - 1 << "\n";
  return 0;
}
