#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, m, l, k = 0;
  cin >> n >> d >> m >> l;
  long long a = l + 1, b = m - 1;
  bool is_ = true;
  if (a == m) {
    a = (((n - 1) * m + l) / d + 1) * d;
    cout << a << endl;
    return 0;
  }
  while (is_) {
    long long temp1;
    if (a > (n - 1) * m + l || b > (n - 1) * m + l) {
      temp1 = (n - 1) * m + l;
      temp1 /= d;
      temp1++;
      cout << temp1 * d << endl;
      return 0;
    }
    if (a % d == 0) {
      cout << a << endl;
      return 0;
    } else if (b % d == 0) {
      cout << b << endl;
      return 0;
    } else {
      int a1 = a / d, b1 = b / d;
      if (b1 > a1) {
        cout << (a1 + 1) * d << endl;
        return 0;
      }
      a += m;
      b += m;
    }
  }
  return 0;
}
