Under construction

Still being built. Things may change

King of cans

Time limit1sMemory limit1024 MB

Summary
Given x bottles worth 2 kroner and y bottles worth 3 kroner, find the maximum number of groups that each sum to exactly 100.
Level

Medium4 of 10

Topics
Math, Greedy, Brute force, Implementation
Solved
No attempts yet

Problem

Lisa, an informatics student at the University of Bergen in Norway, has spent far too much money. To make up for it, she has decided to recycle the empty cans she found in the reading hall. Since Lisa has been in Norway for a while now, she knows that the Norwegian government runs a deposit-refund scheme to encourage recycling of soda bottles: when buying a bottle, the store collects an extra 22 or 33 Norwegian kroner in deposit, depending on bottle size, for each soda bottle you buy. If someone returns an empty bottle to the store to be recycled, the deposit is refunded to the redeemer. So if Lisa manages to find a couple of hundred bottles left behind by wasteful students, it can quickly become surprisingly much money.

As an informatics student, Lisa naturally has some tendencies of OCD, and today it kicks in hard. She will not take any receipt that is not exactly 100100 Norwegian kroner after recycling the soda. The question is this: what is the maximum amount of receipts equaling exactly 100100 Norwegian kroner Lisa can get?

Input

The first and only line has two space-separated integers xx and yy, where 0≤x≤1040 \leq x \leq 10^{4} is the number of bottles whose deposit worth is 22 Norwegian kroner, and 0≤y≤1040 \leq y \leq 10^{4} is the number of bottles whose deposit is worth 33 Norwegian kroner.

Output

Your program should output a single integer, the maximum number of refund receipts Lisa can get which each total exactly 100100 Norwegian kroner.

Examples3

  1. Example 1

    Input
    5 30
    
    Expected output
    1
    
  2. Example 2

    Input
    49 1
    
    Expected output
    0
    
  3. Example 3

    Input
    0 100
    
    Expected output
    0