#include <bits/stdc++.h>
int main(void) {
  unsigned long long int n, d, m, l;
  scanf("%llu %llu %llu %llu", &n, &d, &m, &l);
  unsigned long long int pos = 0llu;
  for (unsigned long long int i = 1; i <= n;) {
    unsigned long long int segP = (i - 1) * m;
    if (pos >= segP && pos <= (segP + l)) {
      unsigned long long int skipSteps = (segP + l - pos) / d;
      pos += skipSteps * d;
    } else
      break;
    pos += d;
    while (pos > (i - 1) * m + l) i++;
  }
  printf("%llu\n", pos);
  return 0;
}
