#include<iostream> using namespace std; int n,cnt,m; int main(){ int a,b; cin>>a>>b; while(1){ cnt++;c int x=(1+cnt*b)/a; if(a*x%b==1){ cout<<x; return 0; } } }