Under construction

Still being built. Things may change

Checkers

Interview

Time limit1sMemory limit512 MB

Summary
Given a white pieces and b black pieces, arrange them in a tower to maximize the number of black stripes, where a stripe is a maximal run of adjacent black pieces.
Level

Easy3 of 10

Topics
Greedy, Math, Implementation, Combinatorics
Solved
No attempts yet

Problem

Dima is bored of playing checkers with himself. Since there is nothing but checker pieces to play with, he came up with the following game.

Each piece he has is either white or black. Dima builds a tower by stacking his pieces on top of each other in some order. A black stripe is a sequence of adjacent black pieces, with either a white piece, or the end of the tower at the bottom and top of it. In other words, two adjacent black pieces always belong to the same black stripe. The goal of the game is to get the maximum number of black stripes in the tower.

The game has just started. Dima has aa white and bb black pieces. What is the maximum number of black stripes he can get in his tower?

Input

The only line of input contains two integers aa and bb, the number of white and black pieces, respectively (0≤a,b≤10180 \le a, b \le 10^{18}).

Output

Output a single integer: the maximum possible number of black stripes.

Examples3

  1. Example 1

    Input
    1 2
    
    Expected output
    2
    
  2. Example 2

    Input
    5 2
    
    Expected output
    2
    
  3. Example 3

    Input
    0 3
    
    Expected output
    1