#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
long long a, b;
signed main() {
  long long n = read(), d = read(), m = read(), l = read();
  for (long long i = 1; i <= n; i++) {
    a = l + (i - 1) * m;
    b = i * m - 1;
    if (a / d != b / d) break;
  }
  cout << a / d * d + d;
  return 0;
}
