#include <bits/stdc++.h>
using namespace std;
int gi() {
  int a;
  scanf("%d", &a);
  return a;
}
long long gli() {
  long long a;
  scanf("%I64d", &a);
  return a;
}
vector<int> g[100004];
int vis[100004];
vector<int> f[100004];
void dfs(int a) {
  vis[a] = 1;
  int l = g[a].size();
  for (int i = 0; i < l; i++) {
    int x = g[a][i];
    if (vis[x]) continue;
    f[a].push_back(x);
    dfs(x);
  }
}
void sw(int &a, int &b) {
  int t = a;
  a = b;
  b = t;
}
void calc(int a, int &lp, int &lc) {
  int l = f[a].size();
  lp = 0;
  lc = 0;
  int mx1 = 0, mx2 = 0;
  for (int i = 0; i < l; i++) {
    int lp0, lc0;
    calc(f[a][i], lp0, lc0);
    lp = (lp0 + 1 > lp ? lp0 + 1 : lp);
    lc = (lc > lc0 ? lc : lc0);
    if (lp0 > mx2) {
      sw(mx2, lp0);
      if (mx2 > mx1) sw(mx1, mx2);
    }
  }
  if (l == 1)
    lc = (lc > lp ? lc : lp);
  else if (l)
    lc = (lc > 2 + mx1 + mx2 ? lc : 2 + mx1 + mx2);
}
int main() {
  int n = gi();
  int m = gi();
  for (int i = 0; i < m; i++) {
    int x = gi();
    int y = gi();
    g[x].push_back(y);
    g[y].push_back(x);
  }
  memset(vis, 0, sizeof(vis));
  dfs(1);
  int lp, lc;
  calc(1, lp, lc);
  printf("%d\n", lc);
  return 0;
}
