Olympic Gold Athletes

Each athlete's skill and fatigue change linearly in time; count those who are the unique max-skill and unique min-fatigue athlete at some time t >= 0.

Hard8GeometryBinary searchSortingImplementationNo attempts yetTime limit1sMemory limit512 MB

Problem

After the Rio Olympics a group of investors is watching NN athletes of the Brazilian team. The group recorded the skill and the fatigue of every athlete at the moment the games ended, and it also found that each of the two values changes at a constant rate. Call the moment the games ended t=0t = 0.

At t=0t = 0 athlete ii has skill HiH_i and fatigue CiC_i. Every unit of time the skill changes by HitH_{it} and the fatigue changes by CitC_{it}, so at time tt athlete ii has skill Hi+HittH_i + H_{it} t and fatigue Ci+CittC_i + C_{it} t.

Athlete ii is a gold athlete at time tt when both conditions hold.

  • The skill of athlete ii is greater than the skill of every other athlete.
  • The fatigue of athlete ii is smaller than the fatigue of every other athlete.

Neither comparison includes equality. When two or more athletes share the largest skill, or two or more share the smallest fatigue, no athlete is a gold athlete at that time. When there is only one athlete, that athlete is a gold athlete at every time.

The group invests only in gold athletes. An athlete receives an investment when there is a real time t0t \ge 0 at which the athlete is a gold athlete. tt may be arbitrarily large, and an athlete who is a gold athlete at t=0t = 0 receives an investment. An athlete who was a gold athlete only at times t<0t < 0 receives nothing. Count the athletes that receive an investment.

Input

The first line contains the number of athletes NN. Line ii of the next NN lines contains four integers HiH_i, HitH_{it}, CiC_i, CitC_{it} separated by spaces: the skill right after the games, the rate of change of the skill, the fatigue right after the games, and the rate of change of the fatigue.

  • 1N1051 \le N \le 10^5
  • 106Hi,Hit,Ci,Cit106-10^6 \le H_i, H_{it}, C_i, C_{it} \le 10^6
  • Hit0H_{it} \ne 0 and Cit0C_{it} \ne 0

Output

Print one line with the number of athletes that receive an investment.