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