#include <bits/stdc++.h> using namespace std; long long a,b,x; int main() { cin>>a>>b; x=b/a; while((a*x)%b!=1) { x++; } cout<<x; return 0; }