struct Point property x : Int32 property y : Int32 def initialize(@x, @y) end end def intersect(p1, p2, p3, p4) ((p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x)) * ((p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x)) <= 0 end n = read_line.to_i a1, a2 = (1..n).map { a, b, c, d = read_line.split.map(&.to_i) [Point.new(a, b), Point.new(c, d)] }.transpose puts (a1 + a2).permutations(2).max_of { |(p1, p2)| p1 == p2 ? 0 : (0...n).count { |i| intersect(p1, p2, a1[i], a2[i]) } }