atcoder#ABC300G. [ABC300G] P-smooth number

[ABC300G] P-smooth number

Score : 600600 points

Problem Statement

A positive integer is called a kk-smooth number if none of its prime factors exceeds kk. Given an integer NN and a prime PP not exceeding 100100, find the number of PP-smooth numbers not exceeding NN.

Constraints

  • NN is an integer such that 1N10161 \le N \le 10^{16}.
  • PP is a prime such that 2P1002 \le P \le 100.

Input

The input is given from Standard Input in the following format:

NN PP

Output

Print the answer as an integer.

36 3
14

The 33-smooth numbers not exceeding 3636 are the following 1414 integers: 1,2,3,4,6,8,9,12,16,18,24,27,32,361,2,3,4,6,8,9,12,16,18,24,27,32,36. Note that 11 is a kk-smooth number for all primes kk.

10000000000000000 97
2345134674