Jealous Numbers

Time limit3sMemory limit256 MB

Problem

In Numberland the prime $p$ envies the prime $q$. To settle the rivalry we count how often $p$ "wins" over $q$ within a range.

For a positive integer $n$ and a prime $x$, let $\alpha(n, x)$ be the largest integer $k$ such that $x^k$ divides $n$; equivalently, $\alpha(n, x)$ is the exponent of $x$ in the prime factorization of $n$.

We say that $n$ is $p$-dominating over $q$ when $\alpha(n, p) > \alpha(n, q)$.

Given $a$, $b$, $p$, and $q$, count how many integers $n$ with $a \le n \le b$ are $p$-dominating over $q$.

Input

A single line with four integers $a$, $b$, $p$, and $q$ ($1 \le a \le b \le 10^{18}$; $2 \le p, q \le 10^9$; $p \ne q$; both $p$ and $q$ are prime).

Output

Print one integer: the number of integers $n$ in $[a, b]$ that are $p$-dominating over $q$.

Hint

For the sample, the integers in $[1, 20]$ that are $3$-dominating over $2$ are $3$, $9$, $15$, and $18$.