#C10398. Max ABA Towers

    ID: 39598 Type: Default 1000ms 256MiB

Max ABA Towers

Max ABA Towers

You are given N A-shaped blocks and M B-shaped blocks. An 'ABA' tower is built with blocks arranged in the order A-B-A. Thus, each tower requires exactly 2 A-shaped blocks and 1 B-shaped block. In mathematical terms, if an 'ABA' tower uses \(2A + 1B\) blocks, then the maximum number of towers you can build is given by \(\min\left(N, \left\lfloor\frac{M}{2}\right\rfloor\right)\).

Your task is to compute the maximum number of complete 'ABA' towers that can be built given the available blocks.

inputFormat

The input is read from stdin and consists of two space-separated integers:

  • N: the number of A-shaped blocks
  • M: the number of B-shaped blocks

outputFormat

Output a single integer to stdout representing the maximum number of complete 'ABA' towers that can be built.

## sample
2 5
2

</p>