#include int main(){ int s, k; std::cin >> s>> k; std::cout << s % k << std::endl; return 0; }