#include using namespace std; int main() { int x,y,w,n; while(cin>>x>>y>>w>>n) cout<<(n-1-(x/w+1)*((x/w+n)/(x/w+1)-1))*w+(x+y)*((x/w+n)/(x/w+1)-1)<