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