#include <bits/stdc++.h>
using namespace std;
long long int n, d, m, l;
int main() {
  while (cin >> n >> d >> m >> l) {
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
      long long int L = (i - 1) * m + l;
      long long int R = i * m;
      long long int p = (L / d) * d + d;
      if (L < p && p < R) {
        ok = false;
        cout << p << endl;
        break;
      }
    }
    if (ok) {
      long long int L = (n - 1) * m + l;
      cout << (L / d) * d + d << endl;
    }
  }
  return 0;
}
