#include using namespace std; int main(){ int a,b; cin>>a>>b; int x = 1; while(true){ if(x%a==b%x){ break; } x++; } cout<