#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int inf=1<<30; const ll INF=1LL<<62; typedef pair P; typedef pair PP; const ll MOD=998244353; const int dy[]={0,1,0,-1}; const int dx[]={1,0,-1,0}; int main(){ ll N,K,M; cin>>N>>K>>M; auto divide=[&](ll n,ll k){ //n!は kで何回割れるか? ll res=0; while(n>0){ res+=n/k; n/=k; } return res; }; ll ans=0; ans+=divide(N,M);//N!はMで何回割れるか? ans-=divide(K,M);//K!はMで何回割れるか? ans-=divide(N-K,M);//(N-K)!はMで何回割れるか? cout<