Arthur and Alexander are number busters. Today they've got a competition. 

Arthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approaches to number bustings. Alexander is just a regular guy. Each second, he subtracts one from his number. In other words, he performs the assignment: c = c - 1. Arthur is a sophisticated guy. Each second Arthur performs a complex operation, described as follows: if b ≥ x, perform the assignment b = b - x, if b < x, then perform two consecutive assignments a = a - 1; b = w - (x - b).

You've got numbers a, b, w, x, c. Determine when Alexander gets ahead of Arthur if both guys start performing the operations at the same time. Assume that Alexander got ahead of Arthur if c ≤ a.

Input

The first line contains integers a, b, w, x, c (1 ≤ a ≤ 2·109, 1 ≤ w ≤ 1000, 0 ≤ b < w, 0 < x < w, 1 ≤ c ≤ 2·109).

Output

Print a single integer — the minimum time in seconds Alexander needs to get ahead of Arthur. You can prove that the described situation always occurs within the problem's limits.

Examples

Input

4 2 3 1 6


Output

2


Input

4 2 3 1 7


Output

4


Input

1 2 3 2 6


Output

13


Input

1 1 2 1 1


Output

0
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		B solver = new B();
		solver.solve(1, in, out);
		out.close();
	}
}

class B {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        long a = in.nextInt();
        int b = in.nextInt();
        int w = in.nextInt();
        int x = in.nextInt();
        long c = in.nextInt();
        int[] to = new int[w];
        int[] cost = new int[w];
        Graph g = new Graph(w, w);
        for (int i = w - 1, j = i - x; i >= 0; i--, j = j == 0 ? w - 1 : j - 1) {
//            System.err.println(i + " to " + j);
            cost[i] = i > j ? 0 : -1;
            to[i] = j;
            g.addDirectedWeightedEdge(i, j, cost[i]);
        }
        BellmanFord bf = new BellmanFord(g);
        bf.getDist(b);
        long moves = 0;
//        System.err.println("Cycle start: " + bf.cycleStart);
        int extra = 0;
        while (b != bf.cycleStart && c > a) {
            extra++;
//            System.err.println("At " + b + " with curr A of " + a);
            a += cost[b];
            b = to[b];
            c--;
            moves++;
        }
//        System.err.println("Extra: " + extra);
        if (c <= a) {
            out.println(moves);
            return;
        }
        int cycleCost = 0;
        int cycleLength = 0;
        int curr = b;
        do {
            cycleLength++;
            if (curr < to[curr]) {
                cycleCost++;
            }
            curr = to[curr];
        } while (curr != b);
//        System.err.println("Length: " + cycleLength + " Cost: " + cycleCost);
        long cycles = 0;
        for (int i = 50; i >= 0; i--) {
            long aDiff = cycleCost * (1L << i);
            long cDiff = cycleLength * (1L << i);
            if (a - aDiff < c - cDiff) {
                a -= aDiff;
                c -= cDiff;
                cycles += 1L << i;
            }
        }
//        System.err.println("Cycles: " + cycles);
        extra = 0;
        moves += cycles * cycleLength;
        while (c > a) {
            extra++;
//            System.err.println("At " + b + " with curr A of " + a);
            a += cost[b];
            b = to[b];
            c--;
            moves++;
        }
//        System.err.println("Extra: " + extra);
        out.println(moves);
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

class Graph {

    public IntArrayList to;
    public IntArrayList capacity;
    public IntArrayList cost;
    public IntArrayList reverse;
    public IntDeque edges[];
    public int vertexCount;
    public int edgeCount;
    public int inDegree[];
    public int outDegree[];

    public Graph(int vertexCount) {
        this(vertexCount, 16);
    }

    public Graph(int vertexCount, int edgeCount) {
        this.to = new IntArrayList(edgeCount);
        this.capacity = new IntArrayList(edgeCount);
        this.cost = new IntArrayList(edgeCount);
        this.reverse = new IntArrayList(edgeCount);
        this.edges = new IntDeque[vertexCount];
        this.vertexCount = vertexCount;
        this.edgeCount = 0;
        this.inDegree = new int[vertexCount];
        this.outDegree = new int[vertexCount];
        for (int i = 0; i < vertexCount; i++) {
            edges[i] = new IntDeque();
        }
    }

    public void addDirectedWeightedEdge(int u, int v, int edgeCost) {
        to.add(v);
        capacity.add(0);
        cost.add(edgeCost);
        reverse.add(-1);
        edges[u].add(edgeCount++);
        inDegree[v]++;
        outDegree[u]++;
    }

    }

class BellmanFord {

    public final long INFINITY = Long.MAX_VALUE;
    public long[] dist;
    public int[] prev;
    boolean[] enqueued;
    public boolean hasCycle;
    public int cycleStart;
    Graph g;

    public BellmanFord(Graph g) {
        dist = new long[g.vertexCount];
        prev = new int[g.vertexCount];
        enqueued = new boolean[g.vertexCount];
        this.g = g;
    }
    public long[] getDist(int src) {
        Arrays.fill(dist, INFINITY);
        hasCycle = false;
        IntDeque q = new IntDeque();

        dist[src] = 0;
        q.add(src);
        for (int i = 0; i < g.vertexCount - 1; i++) {
            for (int v: q) {
                enqueued[v] = false;
            }
            int size = q.size();
            for (int s = 0; s < size; s++) {
                int u = q.poll();
                for (int edge: g.edges[u]) {
                    int v = g.to.get(edge);
                    if (dist[v] > dist[u] + g.cost.get(edge)) {
                        dist[v] = dist[u] + g.cost.get(edge);
                        prev[v] = u;
                        if (!enqueued[v]) {
                            enqueued[v] = true;
                            q.add(v);
                        }
                    }
                }
            }
        }

        CycleCheck: for (int u = 0; u < g.vertexCount; u++) {
            if (dist[u] == INFINITY) {
                continue;
            }
            for (int edge: g.edges[u]) {
                int v = g.to.get(edge);
                if (dist[v] > dist[u] + g.cost.get(edge)) {
                    cycleStart = v;
                    hasCycle = true;
                    break CycleCheck;
                }
            }
        }
        return dist;
    }

}

class IntArrayList {
    int size = 0;
    int[] array;
    public IntArrayList() {
        this(16);
    }
    public IntArrayList(int length) {
        array = new int[length];
    }
    public void ensureCapacity() {
        if (size == array.length) {
            int[] newArray = new int[size << 1];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray;
        }
    }
    public void add(int element) {
        ensureCapacity();
        array[size] = element;
        size++;
    }
    private void checkIndex(int index) {
        if (index < 0 || index >= size) {
            throw new IndexOutOfBoundsException();
        }
    }
    public int get(int index) {
        checkIndex(index);
        return array[index];
    }
    }

class IntDeque implements Iterable<Integer> {

    private int capacity;
    private int size = 0;
    private int front = 0;
    private int back = 0;
    private int[] deque;
    public IntDeque() {
        this(100);
    }
    public IntDeque(int capacity) {
        this.capacity = capacity;
        deque = new int[capacity];
    }
    public void add(int x) {
        addLast(x);
    }
    public void addLast(int x) {
        ensureCapacity();
        size++;
        deque[back++] = x;
        if (back == capacity) {
            back = 0;
        }
    }
    public void ensureCapacity() {
        if (size < capacity) {
            return;
        }
        int[] newDeque = new int[capacity << 1];
        for (int i = 0, j = front; i < size; i++, j++) {
            if (j == capacity) {
                j = 0;
            }
            newDeque[i] = deque[j];
        }
        deque = newDeque;
        capacity <<= 1;
        front = 0;
        back = size;
    }
    public Iterator<Integer> iterator() {
        return new Iterator<Integer>() {
            int done = 0;
            int curr = front;
            public boolean hasNext() {
                return done < size;
            }
            public Integer next() {
                Integer res = deque[curr++];
                if (curr == capacity) {
                    curr = 0;
                }
                done++;
                return res;
            }
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
    public int poll() {
        return pollFirst();
    }
    public int pollFirst() {
        if (size == 0) {
            throw new RuntimeException("IntDeque is empty!");
        }
        size--;
        int res = deque[front++];
        if (front == capacity) {
            front = 0;
        }
        return res;
    }
    public int size() {
        return size;
    }
    public String toString() {
        if (size == 0) {
            return "";
        }
        StringBuilder res = new StringBuilder();
        for (int i: this) {
            res.append(i);
            res.append(" ");
        }
        res.setLength(res.length() - 1);
        return res.toString();
    }
}

