#include <bits/stdc++.h>
using namespace std;
const int MAXX = 1e5 + 9;
vector<int> vec[MAXX], layer[MAXX];
int ans, n, m, t, dis[MAXX], dp[MAXX];
queue<int> qu;
bool isUsed[MAXX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  layer[0].push_back(1);
  dis[1] = 0;
  qu.push(1);
  isUsed[1] = 1;
  while (qu.size() > 0) {
    int v = qu.front();
    for (int i = 0; i < vec[v].size(); i++) {
      if (isUsed[vec[v][i]] != 1) {
        isUsed[vec[v][i]] = 1;
        qu.push(vec[v][i]);
        dis[vec[v][i]] = dis[v] + 1;
        layer[dis[vec[v][i]]].push_back(vec[v][i]);
        t = max(t, dis[vec[v][i]]);
      }
    }
    qu.pop();
  }
  for (int i = t; i >= 0; i--) {
    for (int j = 0; j < layer[i].size(); j++) {
      int m = 0, mm = 0, f = 0, v = layer[i][j];
      for (int k = 0; k < vec[v].size(); k++) {
        if (dis[v] < dis[vec[v][k]]) {
          f++;
          mm = max(mm, dp[vec[v][k]]);
          if (mm > m) swap(mm, m);
        }
      }
      f = f > 2 ? 2 : f;
      m = f == 0 ? m - 1 : m;
      dp[v] = max(dp[v], m + 1);
      ans = max(ans, m + mm + f);
    }
  }
  cout << ans << endl;
}
