If at first you don't succeed
Hazrat Ali
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 AA students, BeaverKing — by BB students and CC students visited both restaurants. Vasya also knows that there are NN 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?
The first line contains four integers — AA, BB, CC and NN (0≤A,B,C,N≤1000≤A,B,C,N≤100).
If a distribution of NN students exists in which AA students visited BugDonalds, BB — BeaverKing, CC — 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 AA, BB, CC or NN (as in samples 2 and 3), output −1−1.
10 10 5 20
5
2 2 0 4
-1
2 2 2 1
-1
Solution