#include <bits/stdc++.h>
using namespace std;
struct bfs {
  int n, mx = INT_MIN;
  int x, y;
  vector<vector<pair<int, int> > > node;
  vector<int> d;
  vector<int> parent;
  int vis[100005] = {0};
  bfs(int _n) {
    n = _n;
    node = vector<vector<pair<int, int> > >(n);
  }
  void make_graph(int a, int b, int c) {
    node[a].push_back({b, c});
    node[b].push_back({a, c});
  }
  void path(int s) {
    queue<pair<int, int> > q;
    d = vector<int>(n, 0);
    parent = vector<int>(n, -1);
    d[s] = 0;
    vis[s] = 1;
    q.push({0, s});
    while (!q.empty()) {
      pair<int, int> u;
      u = q.front();
      q.pop();
      int dist = u.first;
      int N = u.second;
      for (int i = 0; i < node[N].size(); i++) {
        pair<int, int> Q;
        Q = node[N][i];
        int v = Q.first;
        int e = Q.second;
        if (vis[v] == 0) {
          d[v] = d[N] + e;
          parent[v] = N;
          vis[v] = 1;
          if (d[v] > mx) x = v;
          mx = max(mx, d[v]);
          q.push({d[v], v});
        }
      }
    }
  }
};
int main() {
  int test, cs = 0;
  int n, m;
  cin >> n >> m;
  bfs B(n + 1);
  bfs D(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b;
    c = 1;
    B.make_graph(a, b, c);
    D.make_graph(a, b, c);
  }
  for (int i = 1; i <= n; i++) {
    if (B.node[i].size() > 0) {
      B.path(i);
      D.path(B.x);
      cout << D.d[D.x] << endl;
      break;
    }
  }
}
