Tetris

Time limit1sMemory limit128 MB

Problem

Tetris is played on a field with C columns and infinitely many rows. On one move, one of the seven blocks shown below is dropped onto the field.

Before dropping the block, the player may rotate it by 90, 180, or 270 degrees and may move it left or right. Every cell of the block must stay inside the field. The block stops when it rests on the floor or on already-filled cells.

This version uses one extra rule: after the block is placed, no empty cell may remain between the new block and the floor, or between the new block and the existing filled cells. Equivalently, in every column occupied by the block, the lowest cell of the block must touch the current height of that column.

Given the height of each column and the number P of the block to drop, count the number of different positions and rotations in which the block can be placed.

Input

The first line contains two integers C and P (1 <= C <= 100, 1 <= P <= 7), where C is the number of columns and P is the block number.

The second line contains C integers. Each integer is the height of one column, and every height is between 0 and 100, inclusive.

Output

Print one integer: the number of ways to drop the block.