#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, l, m;
  cin >> n >> d >> m >> l;
  long long mx = -1;
  long long bobx = 0;
  for (int i = 1; i <= n; i++) {
    long long x1 = (i - 1) * m;
    long long x2 = (i - 1) * m + l;
    if (bobx > x2) continue;
    if (bobx < x1 || bobx > x2) {
      cout << bobx << endl;
      return 0;
    }
    while (bobx >= x1 && bobx <= x2) {
      bobx = (x2 / d) * d + d;
    }
  }
  cout << bobx << "\n";
  return 0;
}
