FCDC - Factorial Modulo

You are given 2 integers a, b. Find the number of i for which i! is divisible by a but not b. if i! is divisible by a and b, then you should not count that i.

Input

One line that contains a and b.

Output

Output the result in one line.

Example

Input:
2 3

Output:
1

Constraints

1 ≤ a ≤ b ≤ 107

Explanation

2! is the only factorial which is divisible by 2 and not divisible by 3.


Added by:Ruhan Habib
Date:2015-11-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY
Resource:Own Problem

hide comments
2015-11-12 11:26:50 [Lakshman]
My complete brute force code got AC in 0.0 s with python. test case are really week.
2015-11-12 05:21:17
easy if u get the logic.......ac in 2nd go...:)
2015-11-10 08:24:16 Vipul Srivastava
@Prakhar: There are no constraints on i according to the question. It can be anything. Analyse the problem for further insight.

Last edit: 2015-11-10 08:48:07
2015-11-10 05:41:18 Prakhar Dev Gupta
@[LAxman] It can be any I guess.
The thing I wanted to ask was.. there is nothing clearly specified for "i".
Does i lie between a and b or could it be any from 1 to b?
2015-11-10 05:29:16 [Lakshman]
a and b both are prime numbers or it can be any number?
2015-11-09 12:43:06 Ruhan Habib
I've changed the test case, and rejudging has started
2015-11-09 11:57:18 wisfaq
Ruhan, did you change the testcases?
If so you should rejudge and make a post that you did so

(Ruhan) => Yes, I changed the testcase, and rejudging is in process.

Last edit: 2015-11-09 12:42:37
2015-11-08 15:33:10 Howard Roark
"You are given 3 integers a, b". That's 2 integers.

(Ruhan) => Done

Last edit: 2015-11-09 10:56:05
2015-11-07 10:40:33 mehmetin
I think there aren't any big primes in the input, something of the order of 6 or 7 digits.

(Ruhan) => No, and I think I should add a big prime.

Last edit: 2015-11-07 18:23:41
2015-11-07 08:47:59 Ruhan Habib
Hint: This problem has a quite small solution...

Last edit: 2015-11-07 08:48:12
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.