#include <bits/stdc++.h>
using namespace std;
int64_t divup(int64_t D, int64_t d) {
  int64_t q = D / d;
  if (q * d == D)
    return q;
  else
    return q + 1;
}
int main() {
  int64_t n, d, m, l;
  cin >> n >> d >> m >> l;
  int64_t c = 0 + divup(l, d) * d;
  for (;;) {
    double k1 = 1.0 * c / m + 1;
    double k2 = 1.0 * (c - l) / m + 1;
    int64_t k1_int = static_cast<int64_t>(floor(k1));
    int64_t k2_int = static_cast<int64_t>(ceil(k2));
    if (k1_int == k2_int && k1_int <= n) {
      c = divup((k1_int - 1) * m + l, d) * d;
      if (c == (k1_int - 1) * m + l) c += d;
    } else {
      break;
    }
  }
  cout << c << '\n';
}
