#include <bits/stdc++.h>
using namespace std;
int n, d, m, l;
int main() {
  while (~scanf("%d%d%d%d", &n, &d, &m, &l)) {
    long long a, b, idx = 0, k = 1;
    while (k <= n) {
      a = k * l + (k - 1) * (m - l);
      b = k * m - 1;
      if (a / d != b / d) break;
      k++;
    }
    printf("%lld\n", (a / d) * d + d);
  }
  return 0;
}
