#include <bits/stdc++.h>
using namespace std;
int dr[] = {-1, 1, 0, 0};
int dc[] = {0, 0, -1, 1};
long long int mod = 1000000007;
long long int po(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n % 2 == 1) res = ((res) * (x));
    x = (x * x);
    n = n / 2;
  }
  return res;
}
long long int ceil(long long int x, long long int y) {
  if (x % y == 0)
    return x / y;
  else
    return (x / y) + 1;
}
vector<long long int> graph[100005];
bool visited[100005];
long long int level[100005];
long long int timer, n, m;
void dfs(long long int node) {
  visited[node] = 1;
  for (auto i : graph[node]) {
    if (visited[i] == 0) {
      level[i] = level[node] + 1;
      dfs(i);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(1);
  long long int root = 0;
  for (long long int i = 1; i <= n; i++) {
    if (level[i] > level[root]) {
      root = i;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    level[i] = 0;
    visited[i] = 0;
  }
  dfs(root);
  cout << *max_element(level + 1, level + 100003);
}
