title: Count horizontal line segments cut by two vertical lines
body: <p>Given N horizontal line segments with there starting and ending points (Namely A and B) with no restriction on overlapping criteria. Which means we have line segment from (A,0) to (B,0) . Now we can draw two vertical lines passing through these lines. We need to find the maximum line segments that these two lines can cross.
  (If a vertical line touches any horizontal line segment it is also to be counted)</p>
  
  <p>Example : Let us suppose we have 5 line segments :</p>
  
  <pre><code>2 3
  1 3
  1 5
  3 4
  4 5
  </code></pre>
  
  <p>Then We will draw two lines (parallel to Y-axis) crossing X-axis at point 2 and 4. These two lines will touch all the five segments.So answer for this is 5.</p>
  
  <p>But lets suppose we have 3 line segments :</p>
  
  <pre><code>1 2
  3 4
  5 6
  </code></pre>
  
  <p>Then answer is 2 as It is not possible to touch more than two points in this case.</p>
  
  <p>How to solve this problem ? Please help.</p>
  
  <p>Note 1≤N≤10^5 and  0 ≤ A &lt; B ≤ 10^9 </p>