#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int logn = 18;
const int inf = (int)1e9 + 5;
const long long mod = (long long)1e9 + 7;
const long long base = 2204234849;
const long long l_inf = (long long)4e18;
const long double pi = acos(-1.0);
const long double eps = 1e-12;
int n, m;
vector<int> g[maxn];
void dfs(int v, int p, int h, pair<int, int> &best) {
  if (h > best.second) best = make_pair(v, h);
  for (int u : g[v]) {
    if (u != p) dfs(u, v, h + 1, best);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(20);
  cout << fixed;
  srand(566);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  pair<int, int> best;
  dfs(0, -1, 0, best);
  dfs(best.first, -1, 0, best);
  cout << best.second;
  return 0;
}
