#include <bits/stdc++.h>
using namespace std;
const double PI = acos(0) * 2;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
int n, m, h[100100], vs[100100];
vector<int> p, adj[100100];
void DFS(int u, int p) {
  vs[u] = 1;
  for (int i = 0; i < ((int)(adj[u]).size()); i++) {
    int v = adj[u][i];
    if (vs[v]) continue;
    h[v] = h[u] + 1;
    DFS(v, u);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  DFS(1, 0);
  int now = 0;
  for (int i = 1; i <= n; i++) {
    if (!now || h[now] < h[i]) now = i;
  }
  for (int i = 1; i <= n; i++) {
    vs[i] = 0;
    h[i] = 0;
  }
  DFS(now, 0);
  int ans = -1;
  for (int i = 1; i <= n; i++) ans = max(ans, h[i]);
  cout << ans;
}
