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