#include <bits/stdc++.h>
using namespace std;
long long a, b, w, x, c;
pair<long long, long long> f[66][1011];
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(NULL);
  cout << (fixed) << setprecision(6);
  while (cin >> a >> b >> w >> x >> c) {
    for (int k = (0), _b = (w - 1); k <= _b; k++) {
      if (k >= x)
        f[0][k] = make_pair(k - x, 0);
      else
        f[0][k] = make_pair(w - (x - k), 1);
    }
    for (int l = (1), _b = (40); l <= _b; l++) {
      for (int k = (0), _b = (w - 1); k <= _b; k++) {
        int u = f[l - 1][k].first;
        f[l][k] = make_pair(f[l - 1][u].first,
                            f[l - 1][k].second + f[l - 1][u].second);
      }
    }
    long long res = 0;
    while (c > a) {
      long long cur = c - a;
      res += cur;
      c = c - cur;
      for (int l = 0, _a = (40); l < _a; l++)
        if (cur & (1LL << l)) {
          a -= f[l][b].second;
          b = f[l][b].first;
        }
    }
    cout << res << endl;
  }
  return 0;
}
