PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000112. Đếm cặp theo ƯCLN và BCNN (Nastya Studies Informatics)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp theo ƯCLN và BCNN (Nastya Studies Informatics)

Nastya Studies Informatics

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given l,r,x,yl,r,x,y, count the ordered pairs (a,b)(a,b) satisfying l≤a,b≤rl\le a,b\le r, gcd⁡(a,b)=x\gcd(a,b)=x and lcm⁡(a,b)=y\operatorname{lcm}(a,b)=y. The pairs (a,b)(a,b) and (b,a)(b,a) are different if a≠ba\ne b.

Input

One line containing l,r,x,yl,r,x,y.

Output

Print the number of valid ordered pairs.

Subtasks

  • Subtask 1 (20 points): 1≤l≤r≤2001\le l\le r\le200, 1≤x≤y≤2001\le x\le y\le200.
  • Subtask 2 (30 points): 1≤l≤r≤1061\le l\le r\le10^6, 1≤x≤y≤1061\le x\le y\le10^6.
  • Subtask 3 (50 points): 1≤l≤r≤1091\le l\le r\le10^9, 1≤x≤y≤1091\le x\le y\le10^9.

Examples

Input

1 12 1 12

Output

4

Explanation

The four pairs are (1,12),(12,1),(3,4),(4,3)(1,12),(12,1),(3,4),(4,3), all with GCD 11 and LCM 1212.