N = gets.chomp.to_i
points = N.times.map { gets.chomp.split(' ').map(&:to_i) }

if points.size < 3
  puts 0
  exit
end

xy = points.each_with_object(Hash.new { |o, k | o[k] = [] }) { |(x, y), h|
  h[x].push(y)
}

yx = points.each_with_object(Hash.new { |o, k | o[k] = [] }) { |(x, y), h|
  h[y].push(x)
}

add = -> (x, y) do
  xy[x].push(y)
  yx[y].push(x)
end

count = 0

execute = -> do
  current_count = count
  yx.each do |y, xs|
    xs.each_cons(2) do |x1, x2|
      y1 = xy[x1].select { |n| n > y }.first
      y2 = xy[x2].select { |n| n > y }.first
      case
      when y1.nil? && y2.nil?
        next
      when y1.nil? && y2
        add[x1, y2]
        count += 1
      when y1 && y2.nil?
        add[x2, y1]
        count += 1
      when y1 < y2
        add[x2, y1]
        count += 1
      when y2 < y1
        add[x1, y2]
        count += 1
      end
    end
  end
  xy.each do |x, ys|
    ys.each_cons(2) do |y1, y2|
      x1 = yx[y1].select { |n| n > x }.first
      x2 = yx[y2].select { |n| n > x }.first
      case
      when x1.nil? && x2.nil?
        next
      when x1.nil? && x2
        add[x2, y1]
        count += 1
      when x1 && x2.nil?
        add[x1, y2]
        count += 1
      when x1 < x2
        add[x1, y2]
        count += 1
      when x2 < x1
        add[x2, y1]
        count += 1
      end
    end
  end

  execute[] if current_count != count
end

execute[]
puts count