#include using namespace std; int main(){ int e,f; long long int d=1; cin>>e>>f; while((e*d)%f!=1){d++;} cout<