#include <bits/stdc++.h>
using namespace std;
int a, b, m, n;
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> a >> b >> m >> n;
int s[364] = {0, a, b}, t = a + b;
for (int i = 3; i <= n; i++)
{
if (s[i] < m) s[i] = s[i - 1] + s[i - 2], t += s[i];
else
{
cout << t;
return 0;
}
}
return 0;
}