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

#GL0000003. Các số không chia hết (Anti-Division)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Các số không chia hết (Anti-Division)

Anti-Division

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers A,B,C,DA,B,C,D, count integers in [A,B][A,B] that are divisible by neither CC nor DD. Both endpoints are included.

Input

One line with A,B,C,DA,B,C,D.

Output

Print the count of valid integers.

Subtasks

  • Subtask 1 (20 points): 1≤A≤B≤1001 \le A \le B \le 100; 1≤C,D≤1001 \le C,D \le 100
  • Subtask 2 (30 points): 1≤A≤B≤1091 \le A \le B \le 10^{9}; 1≤C,D≤1051 \le C,D \le 10^{5}
  • Subtask 3 (50 points): 1≤A≤B≤10181 \le A \le B \le 10^{18}; 1≤C,D≤1091 \le C,D \le 10^{9}

Examples

Input

4 9 2 3

Output

2

Explanation

Only 55 and 77 among 4,5,6,7,8,94,5,6,7,8,9 are divisible by neither 22 nor 33.