#CT00043. Bội riêng (Exclusive Multiples)

Bội riêng (Exclusive Multiples)

Exclusive Multiples

Version: Phuoc Hung OJ Extended

Problem Statement

You are given four positive integers L,R,A,BL, R, A, B with L≤RL \le R.

An integer xx is called an exclusive multiple if it is divisible by exactly one of AA and BB; that is, it is divisible by AA or by BB, but not by both.

Count the exclusive multiples in the interval [L,R][L,R].

Input

One line contains four positive integers L,R,A,BL, R, A, B separated by spaces.

Output

Print one integer: the number of exclusive multiples in [L,R][L,R].

Subtasks

  • Subtask 1 (40%): 1≤L≤R≤1061 \le L \le R \le 10^6, 1≤A,B≤1091 \le A,B \le 10^9.
  • Subtask 2 (30%): 1≤L≤R≤10121 \le L \le R \le 10^{12}, 1≤A,B≤1091 \le A,B \le 10^9.
  • Subtask 3 (30%): 1≤L≤R≤10181 \le L \le R \le 10^{18}, 1≤A,B≤1091 \le A,B \le 10^9.

Examples

Example 1

Input

1 20 4 6

Output

6

Explanation

The valid numbers are 4,6,8,16,18,204,6,8,16,18,20. Number 1212 is divisible by both 44 and 66, so it is excluded.

Example 2

Input

10 30 5 10

Output

2

Explanation

The multiples of 55 are 10,15,20,25,3010,15,20,25,30. Values 10,20,3010,20,30 are also multiples of 1010, leaving only 1515 and 2525.

Example 3

Input

7 9 2 3

Output

2

Explanation

In [7,9][7,9], number 88 is divisible only by 22 and number 99 only by 33, so there are two valid numbers.