#include <bits/stdc++.h>
using namespace std;
void ONLINE__JUDGE();
const int mod = 998244353;
const int MAX = 1e5 + 9;
long long x, y, m, l, ed, rem;
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  ONLINE__JUDGE();
  cin >> x >> y >> m >> l;
  for (int i = 1; i < x; i++) {
    ed = (i - 1) * m + l;
    rem = ed % y;
    rem = y - rem;
    if (ed + rem < i * m) {
      cout << ed + rem;
      return 0;
    }
  }
  ed = (x - 1) * m + l;
  rem = ed % y;
  rem = y - rem;
  cout << ed + rem;
  return 0;
}
void ONLINE__JUDGE() {}
