Under construction

Still being built. Things may change

Mini-Tetris 3023

Time limit2sMemory limit1024 MB

Summary
Given counts of square, S-tile, and corner tiles, find the widest 2 x n rectangle that some or all of them can tile exactly without overlap.
Level

Medium4 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

A guy named Gry found a new game called "Mini-Tetris 3023". This small version of Tetris is played on a very long grid only 22 cells high. It has just three types of tile:

  • A square made out of 44 tiles in a 2×22 \times 2 grid.
  • An S-tile made out of 44 tiles, 22 on one row and 22 slightly offset on the other.
  • A corner made out of 33 tiles, 11 on one row and 22 on the other.

Tiles may be rotated 00, 9090, 180180, or 270270 degrees to fit amongst each other. However, they cannot overlap or go outside the vertical boundary of the grid.

This game provides aa squares, bb S-tiles, and cc corners. Gry would like to beat the high score by creating the largest possible contiguous 2×n2 \times n rectangle out of some or all of the provided tiles, without any tiles overlapping or sticking out of the rectangle.

Input

The sole line of input contains three integers aa, bb, and cc (0≤a,b,c≤500 \leq a, b, c \leq 50): the number of squares, S-tiles, and corners, respectively.

Output

Output the maximum possible width of the grid, nn, that can be perfectly filled by some or all of the given tiles without overlapping or overstepping the boundaries.

Examples3

  1. Example 1

    Input
    2 2 2
    
    Expected output
    11
    
  2. Example 2

    Input
    1 1 1
    
    Expected output
    2
    
  3. Example 3

    Input
    0 0 0
    
    Expected output
    0