Under construction

Still being built. Things may change

Manly Kwak Cheol-yong

Time limit1sMemory limit256 MB

Summary
Given each player's two card numbers and Kwak Cheol-yong's pair, count how many players have a remainder-difference score under K higher than his.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Our idol Kwak Cheol-yong loves gambling with hwatu cards. This time he wants to try a new game with his friends.

The game is played by MM players using 4×N4 \times N cards. The cards are numbered from 1 to 4×N4 \times N, and no two cards share a number. First, each player takes 2 cards from the 4×N4 \times N cards and discards them. Then each of the MM players draws 2 cards. The winner is decided by the numbers on the two cards drawn in the second round. A player's score is the difference between the remainders when the numbers on their two cards are divided by KK.

After both rounds of drawing, Kwak Cheol-yong wonders whether he can win the game. He wants to know the maximum number of players whose score is higher than his. Help ease his nerves.

Input

The first line contains positive integers NN, MM, and KK. (1≤M≤N≤100,0001 \le M \le N \le 100{,}000, 1≤K≤4×N1 \le K \le 4 \times N)

From the second line through the (M+1)(M+1)-th line, each player's two positive integers aia_i and bib_i are given, which are the numbers on the cards drawn in the first round. (1≤ai,bi≤4×N1 \le a_i, b_i \le 4 \times N)

The (M+2)(M+2)-th line contains two positive integers AA and BB, which are the numbers on the cards Kwak Cheol-yong drew in the second round. (1≤A,B≤4×N1 \le A, B \le 4 \times N)

Output

Print the maximum number of players whose score is higher than Kwak Cheol-yong's score.

Examples1

  1. Example 1

    Input
    5 5 5
    10 2
    3 7
    4 8
    14 6
    12 18
    9 11
    
    Expected output
    1