#include <bits/stdc++.h>
using namespace std;
list<int> listeAdj[100001];
int n, m;
int bfs1(int cur) {
  vector<bool> visite(100001);
  queue<int> file;
  file.push(cur);
  while (!file.empty()) {
    cur = file.front();
    visite[cur] = true;
    file.pop();
    list<int>::iterator it;
    for (it = listeAdj[cur].begin(); it != listeAdj[cur].end(); it++) {
      if (!visite[*it]) file.push(*it);
    }
  }
  return cur;
}
int bfs2(int cur) {
  vector<bool> visite(100001);
  queue<pair<int, int> > file;
  file.push(make_pair(cur, 0));
  int prof;
  while (!file.empty()) {
    cur = file.front().first;
    visite[cur] = true;
    prof = file.front().second;
    file.pop();
    list<int>::iterator it;
    for (it = listeAdj[cur].begin(); it != listeAdj[cur].end(); it++) {
      if (!visite[*it]) file.push(make_pair(*it, prof + 1));
    }
  }
  return prof;
}
int main() {
  cin >> n >> m;
  int xi;
  int yi;
  for (int i = 0; i < m; i++) {
    cin >> xi >> yi;
    listeAdj[xi].push_back(yi);
    listeAdj[yi].push_back(xi);
  }
  xi = bfs1(xi);
  cout << bfs2(xi);
}
