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