Make It Zero

4

1 votes
Problem

Mr. Untitle loves making numbers zero.But he can't make any number randomly 0, he can only do it by using two operations.

He has two numbers a and b and he want to make them zero, using given two operations :-

1.Decrease both numbers by 1(i.e., a=a-1 and b=b-1)

2.Decrease any one number by 2(i.e., a=a-2 or b=b-2)

Since Mr. Untitle is busy watching his favourite videos, help him compute the minimum number of operations to make both numbers a and b zero.If both numbers can't be made 0, output -1.

 

INPUT:

The only line of input contains two integers a and b.

(0<=a,b,<=10^9)

OUTPUT:

Print one integer — the minimum numbers of operations required to make a and b zero.If they can't be made 0 print -1.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Apply operation 2 on b, then b becomes 3.

Apply operation 1 three times which makes both a and b equal to 0.

Minimum 4 operations were needed to make both a  and b zero.

Editor Image

?