#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;
const int INF = INT_MAX / 3;
const int MAXLOG = 20;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, d, m, l;
  cin >> n >> d >> m >> l;
  long long pos = 0;
  for (int i = 1; i <= n; i++) {
    long long f = (i - 1ll) * m, t = f + l;
    if (pos + d < f) {
      cout << pos + d;
      return 0;
    }
    pos = t - t % d;
  }
  cout << pos + d;
}
