n = gets.to_i
edge = (n-1).times.map{gets.split.map(&:to_i)}
vert = (0..n).map{[]}
colors = []

edge.each.with_index{|(a,b),i|
  vert[a] << [b,i]
  vert[b] << [a,i]
}
q = [1,0,0]
while q[0]
  a,parent,parent_color = q.pop
  color = 0
  vert[a].each{|b,i|
    next if b == parent
    color += 1
    color += 1 if color == parent_color
    colors[i] = color
    q << [b,a,color]
  }
end
p colors.max
puts colors