#include using namespace std; using ll=int64_t; int main(){ ll P,Q; cin >> P >> Q; ll La=0,Lb=1; for (int b=1; b<=Q; b++){ int a=(b*P-1)/Q; if (b*La