A. Make a triangle!

A. Make a triangle!

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Masha has three sticks of length aa, bb and cc centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.

What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.

Input

The only line contains tree integers aa, bb and cc (1≤a,b,c≤1001≤a,b,c≤100) — the lengths of sticks Masha possesses.

Output

Print a single integer — the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.

Examples

input

Copy

3 4 5

output

Copy

0

input

Copy

2 5 3

output

Copy

1

input

Copy

100 10 10

output

Copy

81

Note

In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.

In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 22 centimeter stick by one and after that form a triangle with sides 33, 33 and 55 centimeters.

In the third example, Masha can take 3333 minutes to increase one of the 1010 centimeters sticks by 3333 centimeters, and after that take 4848minutes to increase another 1010 centimeters stick by 4848 centimeters. This way she can form a triangle with lengths 4343, 5858 and 100100centimeters in 8181 minutes. One can show that it is impossible to get a valid triangle faster.

要让这个三角形合法,只需满足三角形不等式

即a+b>ca+b>c,设c=max{a,b,c}c=max{a,b,c},上式转化为c<a+bc<a+b

如果已经满足,不需消耗代价

否则消耗c−a−b+1c−a−b+1的代价

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int t=max(a,max(c,b));
    if(2*t<c+b+a)
        printf("0\n");
    else printf("%d\n",2*t-(c+a+b)+1);
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值