#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
const int mod = 1000000007;
const int N = 3e5;
vector<int> g[N];
priority_queue<int> q;
int max_len = INT_MIN;
int max_u;
void dfs(int u, int p, int len) {
  if (g[u].size() == 1) {
    if (len > max_len) {
      max_len = len;
      max_u = u;
    }
  }
  for (auto i : g[u]) {
    if (i != p) {
      dfs(i, u, len + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, a, b;
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1, 0);
  max_len = 0;
  dfs(max_u, -1, 0);
  cout << max_len;
  return 0;
}
