#include<bits/stdc++.h>
using namespace std;
int imax,imin,ans;
void f(int x,int y){
if(x==y){
ans=x*4;
}
else{
if(x!=0 and y!=0){
imax=max(x,y);
imin=min(x,y);
ans+=(imax/imin)*4;
x=imin;
y=imax%imin;
f(x,y);
}
else{
return;
}
}
}
int main(){
long long x,y;
cin>>x>>y;
f(x,y);
cout<<ans;
}
7红WA3黑TLE
各位大佬求救!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!