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

using namespace std;

unsigned long long gcd (unsigned long long a, unsigned  long long b)
{
    return b ? gcd (b, a % b) : a;
}

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