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