水题

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 would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have spoilt the Codeforces round. On the other hand, if the sum of his marks is strictly less than k, 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 all n exams equal exactly k.

Input

The single input line contains space-separated integers n and k (1 ≤ n ≤ 501 ≤ k ≤ 250) — the number of exams and the required sum of marks.

It is guaranteed that there exists a way to pass n exams in the way that makes the sum of marks equal exactly k.

Output

Print the single number — the minimum number of exams that the author will get a 2 for, considering that the sum of marks for all exams must equal k.

Example
Input
4 8
Output
4
Input
4 10
Output
2
Input
1 3
Output
0
Note

In the first sample the author has to get a 2 for all his exams.

In the second sample he should get a 3 for two exams and a 2 for two more.

In the third sample he should get a 3 for one exam.

题意你有n次考试,每次考试的分数只能是2 3 4 5,如果拿到的分数是2是需要重考的。你有一个目标,要求这么多次考试分数的和是k,但是你又不想拿到太多分数2而重考,所以询问最少考2的次数是多少。

题解:如果每场考试都得3分,判断比k多多少,多的部分就是得2分的考试场次,当然肯定要大于0才行。

#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(b/a==2)
        printf("%d\n",a-b%a);
    else
    printf("0\n");
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值