#include<bits/stdc++.h>
using namespace std;
int a,b,x,y;
int gcd(int m,int n){
if(n==0) return m;
else return gcd(n,m%n);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>a>>b>>x>>y;
int res=2*(a+b+1-gcd(a,b));
if(a%2==0||b%2==0) res--;
cout<<res<<endl;
return 0;
}

京公网安备 11010502036488号