#include using namespace std; int main(){ int x,d; cin>>x>>d; while(x%d!=0){ x*=2; } cout<