A. Exams

Source: Internet
Author: User
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 ;}
      
     
    
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.