#include #include using namespace std; int main() { int n, d; cin >> n >> d; if (n == d) { cout << 0 << endl; } if (!(n%d)) { cout << n / d -1 << endl; } else { cout << n - 1 << endl; } return 0; }