#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 5;
const int inf = 21474846495;
void read(int &x) {
  char ch;
  bool flag = 0;
  for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1);
       ch = getchar())
    ;
  for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar())
    ;
  x *= 1 - 2 * flag;
}
vector<int> vec[maxn];
int ans = 0, st = -1;
void dfs(int cnt, int fa, int now) {
  int siz = vec[cnt].size();
  if (now > ans) {
    st = cnt;
    ans = now;
  }
  for (int i = 0; i < siz; i++) {
    int tmp = vec[cnt][i];
    if (tmp == fa) continue;
    dfs(tmp, cnt, now + 1);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    vec[l].push_back(r);
    vec[r].push_back(l);
  }
  dfs(1, -1, 0);
  dfs(st, -1, 0);
  cout << ans;
  return 0;
}
