If at first you don't succeed...
Contest: Codeforces Round 491 (Div. 2)
Difficulty rating: 1000
Tags: implementation

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 format:
The first line contains four integers — $$$A$$$, $$$B$$$, $$$C$$$ and $$$N$$$ ($$$0 \leq A, B, C, N \leq 100$$$).

Output format:
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$$$.

Constraints:
Time limit: 1.0 s
Memory limit: 256.0 MB

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.

Example input:
10 10 5 20

Example output:
5

Example input:
2 2 0 4

Example output:
-1

Editorial:
Всего студенты разбились на 4 группы — те кто посетил только первый ресторан, кто только второй, кто посетил оба ресторана и кто не сдал экзамен. Один из наиболее простых вариантов отсечь все некорректные случаи — посчитать, сколько студентов оказалось в каждой группе. Для первой группы это значение равно $$$A-C$$$, для второй: $$$B-C$$$, для третьей: $$$C$$$, для четвертой: $$$N-A-B+C$$$. Теперь достаточно проверить, что в первых трех группах неотрицательное число студентов, а в последней — положительное. Если это так, то количество студентов в последней группе и есть ответ на задачу. См. решение A_1.cpp.
В общем случае, рекомендуется ознакомиться с методом включений-исключений: https://en.wikipedia.org/wiki/Inclusion
Кроме того, ограничения в задаче позволяют перебрать значения количества студентов в каждой группе за $$$O(N^{4})$$$ и проверить, соответствует ли такое разбиение условию. Если ни одно разбиение не подошло — вывести $$$-1$$$.