#include <stdio.h>

int main(void){
    __int64_t N,M;
    
    scanf("%lld%lld",&N,&M);
    printf("%lld",N/M-(N/M)%1000);
}