#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long i, j, k, n, t, x, y, s = 0, c = 0, l;
  cin >> n >> s >> k >> l;
  j = s;
  for (i = 1; i <= n; i++) {
    x = (i - 1) * k;
    y = x + l;
    if (j < x)
      break;
    else if (j <= y) {
      c = y - j;
      t = c / s + 1;
      j += (t * s);
    }
  }
  cout << j << endl;
}
