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