Exercising Cows Farmer Geoff's N (1 <= N <= 300) cows have become extremely lazy. They lounge around the pastures doing absolutely nothing, not even mooing. FG is terribly upset and has an idea to get the cows back in shape: a fit cow gives more milk! Farmer Geoff drew a starting line parallel to a very wide barn (whose side is at Y=0) and at distance Y (5 <= Y <= 10,000) from that side. Each cow positions herself at a starting place between the barn and the starting line at location X_i,Y_i (1 <= X_i <= 10,000; 1 <= Y_i <= Y); no two cows share the same X coordinate. When the game starts, each cow races directly towards the side of the barn and, when she reaches the barn, she immediately turns around and races back to the starting line, at which point she turns around, races back to the barn, and so on, hopefully until milking time. All but K (1 <= K <= 8) of the N cows move at the same slow pace; the K (1 <= K <= 8) quick cows move twice as fast. Farmer Geoff, of course, moves twice as fast as even these fast cows. FG thought he had fooled the cows into getting exercise, but there turned out to be a catch: if FG does not pet cow as she encounters the starting line to cheer her on; she just gives up. Thus, FG ends up running back and forth along the starting line so he can pet each cow as she approaches y=Y. 5 ------------------ Starting line, Y=5 in this example 4 . . . . . . . C . 3 . C*. . . . . . . * = fast cow Y 2 . . . . . . . . . 1 . . . C . . . . . 0 +---------------+ | B A R N | +---------------+ 0 1 2 3 4 5 6 7 8 <-- X Consider the layout above where the leftmost cow (starting at 1,3) is the fast one. Here is a chart of everyone's position through the first 39 moves: 2 1 1 4 <-- speed t y_C1 y_C2 y_C3 x_FJ 0 3 1 4 1 1 1 0 3 1 2 1 1 2 1 3 3 2 1 1 4 >5 3 0 1 <-- FG pets C1 5 3 4 1 3 6 1 >5 2 3 <-- FG pets C2 7 1 4 3 5 8 3 3 4 7 9 >5 2 >5 7 <-- FG pets C3; C1 gives up 10 1 4 5 11 0 3 3 12 1 2 2 13 2 1 2 14 3 0 2 15 4 1 2 16 >5 2 2 <-- FG pets C2 17 4 3 4 18 3 4 6 19 2 >5 7 <-- FG pets C3 20 1 4 5 31 0 3 3 32 1 2 2 33 2 1 2 34 3 0 2 35 4 1 2 36 >5 2 2 <-- FG pets C2 37 4 3 4 38 3 4 5 39 2 >5 7 ... FG can keep two cows -- and only two cows -- running. Help FG find the maximum number of cows that he can rescue from indolence (i.e., by running indefinitely). FG can position himself at any starting location. PROBLEM NAME: exercise.X INPUT FORMAT: * Line 1: Three space-separated integers: N, K, and Y * Lines 2..K+1: Line i+1 describes fast cow i with two space-separated integers: X_i and Y_i * Lines K+2..N+1: Line i+K+1 describes slow cow i with two space-separated integers: X_i and Y_i SAMPLE INPUT: 3 1 8 1 3 3 1 11 4 OUTPUT FORMAT: * Line 1: One integer representing the maximum number of cows Farmer John can encourage to play the game indefinitely. SAMPLE OUTPUT: 2