#include <bits/stdc++.h>
using namespace std;
long long n, m, d, l;
int main() {
  cin >> n >> d >> m >> l;
  long long x = 0;
  for (long long i = 0; i < n; i++) {
    if (x < i * m) {
      break;
    }
    while (x <= i * m + l) x = (((i * m + l) / d) + 1) * d;
  }
  cout << x << endl;
  return 0;
}
