#include <bits/stdc++.h>
using namespace std;
template <class T>
T toDec(string s) {
  stringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T>
string toStr(T n) {
  string s;
  stringstream is;
  is << n;
  is >> s;
  return s;
}
template <class T>
bool isPrime(T x) {
  if (x <= 1) return false;
  T i;
  for (i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
template <class T>
double dist(T x1, T y1, T x2, T y2) {
  return sqrt(1. * (x2 - x1) * (x2 - x1) + 1. * (y2 - y1) * (y2 - y1));
}
template <class T>
class Prime {
 public:
  vector<T> z;
  Prime() {
    z.resize(1e5 + 7);
    for (int i = (0); i < (((int)z.size())); i++) z[i] = 1;
    z[0] = 0;
    z[1] = 0;
    T j;
    for (int i = (2); i < (((int)z.size())); i++) {
      if (z[i]) {
        j = i + i;
        while (j < ((int)z.size())) {
          z[j] = 0;
          j += i;
        }
      }
    }
  }
};
int main() {
  long long n, d, m, l, k, mn, mx, curr, st, rm, jmp;
  cin >> n >> d >> m >> l;
  curr = 0;
  k = 1;
  mn = (k - 1) * m;
  mx = (k - 1) * m + l;
  while (1) {
    rm = mx - curr;
    jmp = (rm / d) + 1;
    curr += jmp * d;
    if (curr > mx) {
      while (mn + l < curr && k < n) {
        k++;
        mn = (k - 1) * m;
        mx = (k - 1) * m + l;
      }
      if (curr < mn) break;
      if (k == n && mx < curr) {
        break;
      }
    }
  }
  cout << curr << "\n";
  return 0;
}
