#include <bits/stdc++.h>
using namespace std;
float DFS(map<float, vector<pair<float, float>>> graph, float node1,
          int option) {
  stack<float> s;
  float k, c;
  map<float, int> visited;
  map<float, float> cost;
  float Snode = node1;
  for (auto it = graph.begin(); it != graph.end(); it++) {
    visited[it->first] = 0;
    cost[it->first] = 0;
  }
  int h = 0;
  s.push(node1);
  while (s.empty() != 1) {
    if (visited[Snode] == 0) {
      visited[Snode] = 1;
      for (auto it0 = graph[Snode].begin(); it0 != graph[Snode].end(); it0++) {
        k = it0->first;
        if (visited[k] == 0) {
          cost[k] = it0->second + cost[Snode];
          s.push(k);
        }
      }
    }
    Snode = s.top();
    s.pop();
  }
  auto res = max_element(
      cost.begin(), cost.end(),
      [](const pair<float, float>& p1, const pair<float, float>& p2) {
        return p1.second < p2.second;
      });
  if (option == 1) {
    return res->second;
  } else {
    return res->first;
  }
}
int main() {
  map<float, vector<pair<float, float>>> graph, graph1;
  map<float, int> vist;
  long long int n, a, b, c;
  cin >> n;
  cin >> c;
  for (int i = 1; i < n; i++) {
    cin >> a;
    cin >> b;
    c = 1;
    graph[a].push_back(make_pair(b, c));
    graph[b].push_back(make_pair(a, c));
    vist[a] = 0;
    vist[b] = 0;
  }
  cout << DFS(graph, DFS(graph, 1, 0), 1);
  return 0;
}
