#include int main() { int s, k; scanf("%d %d", &s, &k); printf("%d\n", s%k); return 0; }