#include using namespace std; #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; ll N,D; int main(){ cin>>N>>D; if(N==D){ cout << 0 << endl; return 0; } D = min(D,N-D); ll M = N % D; if(M==0){ cout << N / D - 1 << endl; return 0; } cout << N / M - 1 << endl; }