#include <bits/stdc++.h>
using namespace std;
unsigned long long n, d, m, l;
unsigned long long steps = 0;
int main() {
  cin >> n >> d >> m >> l;
  int k = 1;
  for (int k = 1; k <= n; k++) {
    unsigned long long mul = ((k - 1) * m + l) / d;
    steps = (d * mul) + d;
    if (steps > (k - 1) * m + l && steps < (k * m)) {
      cout << steps;
      break;
    }
    if (k == n) {
      cout << steps;
      break;
    }
  }
  return 0;
}
