N, M = gets.chomp.split.map(&:to_i)
a_to_b = []
have_friend = {}
M.times{
  a, b = gets.chomp.split.map(&:to_i)
  a_to_b.push ([a,b])
  a_to_b.push ([b,a])
  have_friend[a] ||= true
  have_friend[b] ||= true
}

def dijkstra(graph, start)
  h = graph.map {|x| [x[0], x[1].keys]}.to_h

  shortest = Hash.new(Float::INFINITY)
  pred = {}
  done = h.keys.map {|node| [node, false]}.to_h

  shortest[start] = 0

  loop do
    u = nil
    h.each_key.reject {|node| done[node]}.each do |node|
      u = node if !u or shortest[node] < shortest[u]
    end
    break unless u
    done[u] = true

    h[u].each do |v|
      if (a = shortest[u] + graph[u][v]) < shortest[v]
        shortest[v] = a
        pred[v] = u
      end
    end
  end

  [shortest, pred]
end

def make_graph person_to_person
  graph = {}
  person_to_person.each{ |from_person, to_person|
    graph[from_person] ||= {}
    graph[from_person][to_person] = 1
  }
  graph
end

graph = make_graph a_to_b
#p graph
#exit
d_max = 1
have_friend.each_key{ |person|
  tmp = dijkstra graph, person
  d_max = [d_max, tmp[0].size].max
}

puts (d_max + 0)
