#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
const long double E = 1e-10;
unsigned char ccc;
bool _minus = false;
template <typename T>
inline T sqr(T t) {
  return (t * t);
}
inline void read(long long &n) {
  n = 0;
  _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
inline void read(int &n) {
  n = 0;
  _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
char wwww[12];
int kkkk;
inline void write(long long y) {
  long long x = y;
  kkkk = 0;
  if (!x)
    ++kkkk, wwww[kkkk] = '0';
  else
    while (x) {
      ++kkkk;
      wwww[kkkk] = char(x % 10 + '0');
      x /= 10;
    }
  for (int i = kkkk; i >= 1; --i) putchar(wwww[i]);
  putchar(' ');
}
const int MAX = 1e5 + 1;
vector<int> vec[MAX];
bool used[MAX];
int dist[MAX];
int size = 0;
int _pos = 0;
int max_dist = 0;
void dfs(int pos, int d) {
  size++;
  if (d == 0) {
    max_dist = 0;
  }
  if (d >= max_dist) {
    max_dist = d;
    _pos = pos;
  }
  dist[pos] = d;
  used[pos] = true;
  for (int i = 0; i < (int)vec[pos].size(); i++) {
    if (!used[vec[pos][i]]) {
      dfs(vec[pos][i], d + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  srand(time(NULL));
  cout.precision(5);
  cout << fixed;
  int n, m;
  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);
  }
  _pos = 1;
  for (int i = 0; i < 3; i++) {
    memset(used, 0, sizeof(used));
    dfs(_pos, 0);
  }
  cout << dist[_pos] << "\n";
}
