#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, j, s, h;
  cin >> n;
  cin >> j;
  cin >> s;
  cin >> h;
  long long loc = 0;
  if (h == s - 1 || j == s) {
    loc = ((n * s / j) - 1) * j;
  }
  while (1) {
    long long int platform = loc / s;
    if (platform >= n) break;
    long long int pos = loc % s;
    if (pos > h) break;
    loc += j;
  }
  cout << loc << "\n";
  return 0;
}
