Two delivery fleets each log their trucks' arrival times at a depot, sorted in non-decreasing order: fleet A has n arrival times and fleet B has m arrival times. Count the number of cross pairs (i, j) — one truck from fleet A, one truck from fleet B — whose arrival times differ by at most a maximum gap D, i.e. |A[i] - B[j]| <= D. Every truck in A may be paired with every qualifying truck in B (a single truck can appear in multiple counted pairs).
Input format
Line 1: three integers n, m, and D.
Line 2: n space-separated integers, sorted non-decreasing — fleet A's arrival times.
Line 3: m space-separated integers, sorted non-decreasing — fleet B's arrival times.
Output format
A single integer: the number of pairs (i, j) with |A[i] - B[j]| <= D.
Constraints
- 1 ≤ n, m ≤ 100000
- 0 ≤ D ≤ 2000000000
- -1000000000 ≤ each arrival time ≤ 1000000000
- Both logs are individually sorted in non-decreasing order.