#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
long long d,a,b;
long long n;
long long t1,t2;
long long t3,t4;
int main()
{
freopen("mountain.in","r",stdin);
freopen("mountain.out","w",stdout);
//freopen("test.in","r",stdin);
//freopen("test.out","w",stdout);
int s1;
cin>>n>>d>>a>>b;
t1=(n-1)/2;
//xiang shang xun dong de shi jian
// wei zhi hui yuan lai
s1=b-a;
if((n-1)%2==0)
{
if(fabs(s1)>=d)
{
t2=s1/d;
}
}
else
{
if(fabs(s1)>=d) t2=s1/d+1;
}
t4=(n-1+t2)/2;
cout<<d*t4+a<<endl;
return 0;
}