#include <bits/stdc++.h>
using namespace std;
long long gcd(long long m, long long n) {
  long long r;
  while (n != 0) {
    r = m % n;
    m = n;
    n = r;
  }
  return m;
}
long long expmod(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) x = (x * y) % 1000000007;
    y = (y * y) % 1000000007;
    b >>= 1;
  }
  return (x) % 1000000007;
}
long long inv(long long n) { return expmod(n, 1000000007 - 2); }
int main() {
  long long n, d, m, l;
  cin >> n >> d >> m >> l;
  for (long long x = 1; x < m; x++) {
    long long p = x * d;
    long long remain = p % m;
    if (remain > l) {
      cout << p << endl;
      return 0;
    }
  }
  long long border = (n - 1) * m + l;
  long long num = border / d;
  num++;
  cout << num * d << endl;
  return 0;
}
