#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  long long n, d, m, l, ans, i;
  while (~scanf("%lld %lld %lld %lld", &n, &d, &m, &l)) {
    ans = 0;
    for (i = 1; i <= n; i++) {
      if (ans < (i - 1) * m) break;
      while (ans <= (i - 1) * m + l) ans = (((i - 1) * m + l) / d) * d + d;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
