Exactly One Subject
0.5s 256MAfter the midterm, a teacher is tallying the class's English and Math results: \(E\) students passed English, \(M\) students passed Math, and \(B\) of them passed both subjects.
The teacher wants to know how many students passed exactly one of the two subjects, that is, the number of students who passed English but not Math, plus the number who passed Math but not English. Write a program to work it out.
Input
The input contains one line with three integers \(E\), \(M\) and \(B\), separated by spaces: the number of students who passed English, who passed Math, and who passed both.
Constraints
- \(0 \le B \le E \le 1000\)
- \(0 \le B \le M \le 1000\)
Output
Output one integer: the number of students who passed exactly one subject.
Sample Input 1
15 20 8
Sample Output 1
19
Sample Input 2
6 10 0
Sample Output 2
16
Sample Input 3
9 9 9
Sample Output 3
0
Sample Explanation
Try to work out why Sample 1 gives 19 before opening this
Among the \(15\) students who passed English, \(8\) also passed Math, so \(15 - 8 = 7\) students passed only English. Likewise, \(20 - 8 = 12\) students passed only Math. Together that is \(7 + 12 = 19\) students.
In Sample 3, all \(9\) students passed both subjects, so nobody passed exactly one, and the answer is \(0\).
Log in to write and submit code. Creating an account is free.