#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = {1, -1, -1, 1, 0, 0, -1, 1};
int dy2[] = {1, -1, 1, -1, 1, -1, 0, 0};
int kmx[] = {-1, -1, 1, 1, 2, -2, 2, -2};
int kmy[] = {2, -2, 2, -2, -1, -1, 1, 1};
class Timer {
 public:
  clock_t T;
  Timer() { T = clock(); }
  ~Timer() {
    fprintf(stderr, "\n%.3f\n", double(clock() - T) / CLOCKS_PER_SEC);
  }
};
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
long long readL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 1e5 + 5;
vector<int> g[N];
int n;
pair<int, int> ret;
void dfs(int i = 0, int d = 0, int p = -1) {
  if (d > ret.second) ret.first = i, ret.second = d;
  for (int j = 0; j < g[i].size(); j++) {
    if (g[i][j] != p) {
      dfs(g[i][j], d + 1, i);
    }
  }
}
int main() {
  n = read();
  int m = read();
  while (m--) {
    int a = read();
    int b = read();
    a--, b--;
    g[a].push_back(b);
    swap(a, b);
    g[a].push_back(b);
  }
  dfs();
  dfs(ret.first);
  printf("%d\n", ret.second);
  return 0;
}
