#include int i,j; int main(){scanf("%d%d",&i,&j);printf("%d",i%j);}