Psychological comfort P97833


Statement
 

pdf   zip

Professor Oak is getting old, as he can notice at the gym. Now, when he is on the running machine, he needs some psychological tricks to go on. For instance, supose that he decides to run for m=20m = 20 minutes. Then, when he has been running for 2 minutes, he thinks “already 1/101/10 done”. Similarly, at the minute 17, he thinks “only 3/203/20 left”. Note that Prof. Oak solely likes fractions whose only prime factors (when simplified) are 2, 3 and 5. So, for m=20m = 20, the minute 7 is not psychologically comforting, because both 7/207/20 and 13/2013/20 have factors other than 2, 3 and 5.

Given mm, how many psychologically comforting minutes will Prof. Oak enjoy?

Input

Input consists of several cases, each with an mm between 1 and 101510^{15}.

Output

For every mm, print the number of psychologically comforting minutes between 1 and m1m-1.

Public test cases
  • Input

    1
    10
    20
    66
    81
    1000000007
    1000000000000000
    

    Output

    0
    9
    17
    5
    50
    0
    12909
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++