#include <bits/stdc++.h>
using namespace std;
int v[1000000] = {};
int main() {
  int n = ({
    int x;
    scanf("%d", &x);
    x;
  }),
      d = ({
        int x;
        scanf("%d", &x);
        x;
      }),
      m = ({
        int x;
        scanf("%d", &x);
        x;
      }),
      l = ({
        int x;
        scanf("%d", &x);
        x;
      });
  long long x = 0;
  v[0] = 1;
  long long c = 0;
  while (1) {
    x += d;
    if (x >= m * (long long)n || x % m > l)
      break;
    else if (v[x % m]) {
      if (m * (long long)n % d == 0)
        cout << m * (long long)n;
      else
        cout << (m * (long long)n) / d * d + d;
      return 0;
    } else {
      v[x % m] = 1;
    }
  }
  cout << x << endl;
}
