#include<iostream>
#include<cmath>
#include<ctime>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cstdio>
using namespace std;
#define jiba unsigned long long int
jiba s[101],a,n,m,x;
int febonaqi(jiba n)
{
for(int i=3;i<=n;i++)
{
s[i]=s[i-1]+s[i-2];
}
}
int main()
{
cin>>a>>n>>m>>x;
s[1]=s[2]=1;
febonaqi(x);
if(x==n)
{
cout<<s[x]*a-m;
return 0;
}
cout<<s[x]*a-2;
return 0;
}