#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const double PI = 3.14159265;
int main() {
  long long N, d, m, l;
  cin >> N >> d;
  cin >> m >> l;
  long long pos = 0, onPlat = 1, platEnd = l, tn;
  N--;
  while (onPlat) {
    pos += ((platEnd - pos) / d + 1) * d;
    while (pos > platEnd && N) {
      platEnd += m;
      N--;
    }
    if (platEnd - l > pos || pos > platEnd) {
      onPlat = 0;
    }
  }
  cout << pos;
}
