Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
one day the codeforces round author sat exams. he had n exams and he needed to get an integer from 2 to 5 for
each exam. he will have to re-sit each failed exam, I. e. the exam that gets Mark 2 .
The author wowould need to spend too much time and effort to make the sum of his marks strictly moreK. That cocould have spoilt the codeforces
Round. On the other hand, if the sum of his marks is strictly lessK, The author's mum won't be pleased at all.
The codeforces authors are very smart and they always get the mark they choose themselves. Also, the codeforces authors just hate re-sitting exams.
Help the author and find the minimum number of exams he will have to re-sit if he passes the exams in the way that makes the sum of marks for allNExams
Equal exactlyK.
Input
the single input line contains space-separated integers n and K ( 1 hour ≤ hour n hour ≤ hour 50 , 1 records ≤ cost K records ≤ cost 250 )
-the number of exams and the required sum of marks.
It is guaranteed that there exists a way to passNExams in the way that makes the sum of marks equal exactlyK.
Output
Print the single number-the minimum number of exams that the author will get2For, considering that the sum of marks for all exams must equalK.
Sample test (s) Input
4 8
Output
4
Input
4 10
Output
2
Input
1 3
Output
0
Note
In the first sample the author has to get2For all his exams.
In the second sample he shocould get3For two exams and2For
Two more.
In the third sample he shoshould get3For one exam.
Problem-solving Description: N tests are given in the question. Each test has a score of 2 to 5. How can I score a score that equals K and gives a maximum score of 2. This can be analyzed in this way. If every test gets 3 points and the number of more than K is determined, the more part is the 2-point test session. Of course, it must be greater than 0.
# include
# include
# include
# include
# include
using namespace STD; int main () {int N, K; scanf ("% d", & N, & K); printf ("% d \ n ", max (3 * n-k, 0); Return 0 ;}