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