#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, d, m, l;
  cin >> n >> d >> m >> l;
  long long int tmp = 0;
  while (1) {
    if (tmp / m >= n || (tmp / m) * m + l < tmp && ((tmp / m) + 1) * m > tmp)
      break;
    if ((tmp % m) == 0) {
      tmp += (l / d) * d;
      tmp += d;
    } else {
      tmp += (abs(abs((tmp / m) * m - tmp) - l) / d) * d;
      tmp += d;
    }
  }
  cout << tmp << endl;
}
