n = gets.to_i xy = [] n.times { xy << gets.split(" ").map{|s| s.to_i} } dist = [] 0.upto(n-1) {|i| xi, yi = xy[i] (i+1).upto(n-1) {|j| xj, yj = xy[j] d = (xi-xj)**2 + (yi-yj)**2 dist << [d, i, j] } } dist.sort! alive = Array.new(n, 1) remove = 0 while alive.sum > 1 do d, i, j = dist.shift if i == 0 and alive[j] == 1 then remove += 1 alive[j] = 0 elsif alive[i] == 1 and alive[j] == 1 then alive[i] = alive[j] = 0 end end puts remove