#include <bits/stdc++.h>
using namespace std;
long long n, d, m, l;
bool check(long long x) {
  if (x % m > l) return 0;
  if (x > (n - 1) * m + l) return 0;
  return 1;
}
int main() {
  while (cin >> n >> d >> m >> l) {
    long long x = 0;
    while (check(x)) {
      int mod = x % m;
      int k = max(1LL, (l - mod) / d);
      x += k * d;
    }
    cout << x << endl;
  }
  return 0;
}
