#include <iostream>
#include <cstdio>
#include <vector>
#include <assert.h>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    freopen("mars.in", "r", stdin);
    freopen("mars.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    long long ans = 0;
    unsigned long long fact = 1;
    for (unsigned long long i = 1; i <= n; ++i)
    {
        fact *= i;
        while (fact % k == 0)
        {
            fact /= k;
            ans++;
        }
    } 
    cout << ans << endl;
}
