#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, m, l, i, a, b;
  cin >> n >> d >> m >> l;
  for (a = l, b = m; a <= (n - 2) * m + l, b <= (n - 1) * m; a += m, b += m) {
    i = b / d;
    if (b % d == 0) i--;
    if (a / d != i) {
      cout << a / d * d + d << endl;
      return 0;
    }
  }
  cout << ((n - 1) * m + l) / d * d + d << endl;
  return 0;
}
