#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, s = 0, x, y;
  cin >> n >> d >> x >> y;
  long long an = 0, l, r;
  for (int i = 1; i <= n; i++) {
    l = (i - 1) * x + y;
    r = (i)*x;
    if (l / d != (r - 1) / d) {
      cout << (l / d + 1) * d;
      return 0;
    }
  }
  cout << (l / d + 1) * d;
  return 0;
}
