#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return abs(a * b) / gcd(a, b); }
int main() {
  long long n, d, m, l, mvd = 0;
  cin >> n >> d >> m >> l;
  int c = 1;
  while (mvd % m <= l && mvd <= (n - 1) * m + l) {
    mvd += d * ((l - mvd % m) / d + 1);
  }
  cout << mvd << endl;
}
