#include <bits/stdc++.h>
int main() {
  long long k, m, d, l, i, j, sum = 0, flag = 0;
  scanf("%I64d%I64d%I64d%I64d", &k, &d, &m, &l);
  for (i = 1; i <= k; ++i) {
    sum = i * d;
    if (sum % m > l) {
      printf("%I64d\n", sum);
      return 0;
    }
  }
  sum = (k - 1) * m + l;
  sum /= d;
  sum = (sum + 1) * d;
  printf("%I64d\n", sum);
  return 0;
}
