#include <bits/stdc++.h>
using namespace std;
const int N = 100032;
int n, m;
vector<int> G[N];
bool ck[N];
int d[N], ans;
void dfs(int u) {
  n--;
  ck[u] = true;
  for (int v : G[u])
    if (!ck[v]) {
      dfs(v);
      ans = max(ans, d[u] + d[v] + 1);
      d[u] = max(d[u], d[v] + 1);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1);
  cout << ans << endl;
  return 0;
}
