#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> arr[100001];
bool c = false;
long long ans2 = 0;
vector<pair<int, int>> nod;
bool visited[100001];
void dfs1(int node, long long ans) {
  visited[node] = true;
  bool leaf = true;
  for (int i = 0; i < arr[node].size(); i++) {
    int child = arr[node][i];
    if (!visited[child]) {
      dfs1(child, ans + 1);
      leaf = false;
    }
  }
  if (leaf) nod.push_back(make_pair(node, ans));
}
void dfs2(int node, long long ans) {
  visited[node] = true;
  for (int i = 0; i < arr[node].size(); i++) {
    int child = arr[node][i];
    if (!visited[child]) {
      dfs2(child, ans + 1);
    }
  }
  ans2 = max(ans, ans2);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    arr[x].push_back(y);
    arr[y].push_back(x);
  }
  dfs1(1, 0);
  for (int i = 0; i <= n; i++) {
    visited[i] = false;
  }
  int node = nod[0].first;
  long long max = nod[0].second;
  for (int i = 1; i < nod.size(); i++) {
    if (nod[i].second > max) {
      max = nod[i].second;
      node = nod[i].first;
    }
  }
  dfs2(node, 0);
  cout << ans2 << endl;
}
