#include <bits/stdc++.h>
int main() {
  long long int s, start, len, count = 0, n, d, m, l, t;
  scanf("%I64d%I64d%I64d%I64d", &n, &d, &m, &l);
  len = n * m - m + l;
  start = l / d;
  count += start;
  s = (++count) * d;
  for (;;) {
    if (s > len) break;
    t = s % m;
    if (t > l) break;
    start = (l - t) / d;
    count += start;
    s = (++count) * d;
  }
  printf("%I64d", s);
}
