#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
vector<int> g[M];
int ma = -1, node;
void dfs(int u, int p, int d) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == p) continue;
    dfs(v, u, d + 1);
  }
  if (d > ma) {
    ma = d;
    node = u;
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 1, 0);
  ma = -1;
  dfs(node, node, 0);
  cout << ma;
  return 0;
}
