#include <bits/stdc++.h>
using namespace std;
long long n, d, m, l, x, k, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> d >> m >> l;
  for (k = 0; k < n; k++) {
    L = m * k;
    R = L + l;
    if (x < L) return cout << x, 0;
    if (x > R) continue;
    x += (R - x) / d * d + d;
  }
  return cout << x, 0;
}
