Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after the exam.

Some of them celebrated in the BugDonalds restaurant, some of them — in the BeaverKing restaurant, the most successful ones were fast enough to celebrate in both of restaurants. Students which didn't pass the exam didn't celebrate in any of those restaurants and elected to stay home to prepare for their reexamination. However, this quickly bored Vasya and he started checking celebration photos on the Kilogramm. He found out that, in total, BugDonalds was visited by A students, BeaverKing — by B students and C students visited both restaurants. Vasya also knows that there are N students in his group.

Based on this info, Vasya wants to determine either if his data contradicts itself or, if it doesn't, how many students in his group didn't pass the exam. Can you help him so he won't waste his valuable preparation time?

Input

The first line contains four integers — A, B, C and N (0 ≤ A, B, C, N ≤ 100).

Output

If a distribution of N students exists in which A students visited BugDonalds, B — BeaverKing, C — both of the restaurants and at least one student is left home (it is known that Vasya didn't pass the exam and stayed at home), output one integer — amount of students (including Vasya) who did not pass the exam. 

If such a distribution does not exist and Vasya made a mistake while determining the numbers A, B, C or N (as in samples 2 and 3), output -1.

Examples

Input

10 10 5 20


Output

5

Input

2 2 0 4


Output

-1

Input

2 2 2 1


Output

-1

Note

The first sample describes following situation: 5 only visited BugDonalds, 5 students only visited BeaverKing, 5 visited both of them and 5 students (including Vasya) didn't pass the exam.

In the second sample 2 students only visited BugDonalds and 2 only visited BeaverKing, but that means all 4 students in group passed the exam which contradicts the fact that Vasya didn't pass meaning that this situation is impossible.

The third sample describes a situation where 2 students visited BugDonalds but the group has only 1 which makes it clearly impossible.
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	private PrintWriter pw;
	private long mod = 1000000000 + 7;

	private StringBuilder ans_sb;
	private int size = 1000005;
	private void soln() {
		int n = nextInt();
		int m = nextInt();
		int c = nextInt();
		int d = nextInt();
		if(n >= c && m >= c) {
			n -= c;
			m -= c;
			if(n+m+c < d) {
				pw.println(d-n-m-c);
			}else
				pw.println(-1);
		}else
			pw.println(-1);
	}		
	private int contains(int[] arr, int x) {
		for(int i=0;i<arr.length;i++) {
			if(arr[i] == x) {
				return i;
			}
		}
		return -1;
	}
	private class Query implements Comparable<Query>{
		int i, idx, x, y, mul;
		public Query(int a, int b, int c, int d, int m) {
			i = a;
			idx = b;
			x = c;
			mul = m;
			y = d;
		}
		@Override
		public int compareTo(
				Query o)
		{
			return this.i - o.i;
		}
	}
	private long[][] pow(int a, int b, int n) {
		long[][] mat = {{a,0,b},{1L,0,0},{0,1L,0}};
		if(n == 1)
			return mat;
		long[][] res = pow(a,b,n/2);
		res = multiply(res,res);
		if((n&1) != 0)
			res = multiply(mat, res);
		return res;
	}
	private long[][] multiply(long[][] a, long[][] b) {
		long[][] ret = new long[3][3];
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					ret[i][j] = (ret[i][j] + ((a[i][k]*b[k][j])%mod))%mod;
		return ret;
	}
	private class Node{
		Node left,right;
		int sum;
		public Node(int v) {
			sum=v;
		}
		public Node (Node left,Node right){
			this.left = left;
			this.right = right;
			if (left != null)
				sum = sum + left.sum;
			if (right != null)
				sum = sum + right.sum;
		}
	}
	public Node build(int l,int r) {
		if(l==r)
			return new Node(0);
		int mid=l+((r-l)>>1);
		Node left=build(l,mid);
		Node right=build(mid+1,r);
		return new Node(left,right);
	}
	public int query(int l,int r, Node root) {
		return queryutil(l,r,root,0,size-1);
	}
	public int queryutil(int x,int y,Node node,int l,int r) {
		if(l>y || x>r) 
			return 0;
		if(x <= l && r<=y)
			return node.sum;
		int mid=l+((r-l)>>1);
		return queryutil(x,y,node.left,l,mid) + queryutil(x,y,node.right,mid+1,r);
	}
	public Node newNode(int pos,int val,Node node) {
		return newNodeUtil(pos,val,node,0,size-1);
	}
	public Node newNodeUtil(int pos,int val,Node node,int l, int r) {
		if(l==r)
			return new Node(val);
		int mid=l+((r-l)>>1);
		if(pos<=mid) {
			Node left=newNodeUtil(pos,val,node.left,l,mid);
			return new Node(left,node.right);
		}else {
			Node right=newNodeUtil(pos,val,node.right,mid+1,r);
			return new Node(node.left,right);
		}
	}
	private void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	private long pow(long a, long b, long c) {
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}

	private long gcd(long n, long l) {
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				new Main().solve();
			}
		}, "1", 1 << 26).start();
		//new Main().solve();
	}

	public StringBuilder solve() {
		InputReader(System.in);
		/*
		 * try { InputReader(new FileInputStream("C:\\Users\\hardik\\Desktop\\in.txt"));
		 * } catch(FileNotFoundException e) {}
		 */
		pw = new PrintWriter(System.out);
		// ans_sb = new StringBuilder();
		soln();

		pw.close();
		// System.out.println(ans_sb);
		return ans_sb;
	}

	public void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private int nextInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private long nextLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private char nextChar() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}