#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, d, m, l;
  cin >> n >> d >> m >> l;
  pair<long long, long long> coordinates[n];
  long long ans = 0;
  coordinates[0].first = 0;
  coordinates[0].second = l;
  for (int i = 1; i < n; i++) {
    coordinates[i].first = i * m;
    coordinates[i].second = i * m + l;
    long long j = (coordinates[i - 1].second / d) * d + d;
    if (j < coordinates[i].first) {
      ans = j;
      cout << ans;
      return 0;
    }
  }
  ans = (coordinates[n - 1].second / d) * d + d;
  cout << ans;
  return 0;
}
