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