#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
const int INFTY = 1e7;
bool vis[1005];
vector<vector<int> > AdjList(100005);
long long N, M;
long long bfs(int u, bool fst) {
  queue<int> q;
  q.push(u);
  vector<long long> d(N, 1e18);
  d[u] = 0;
  long long maxi = 0;
  long long best = u;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < ((int)AdjList[u].size()); i++) {
      int v = AdjList[u][i];
      if (d[v] == 1e18) {
        d[v] = d[u] + 1;
        q.push(v);
        if (d[v] > maxi) {
          maxi = d[v];
          best = v;
        }
      }
    }
  }
  return (fst ? bfs(best, false) : maxi);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < (M); i++) {
    long long u, v;
    cin >> u >> v;
    AdjList[u - 1].push_back(v - 1);
    AdjList[v - 1].push_back(u - 1);
  }
  cout << bfs(0, true) << endl;
}
