You are given a grid of n rows and m columns consisting of lowercase English letters a, b, c, and d.
We say 4 cells form a "nice-quadruple" if and only if
A cell is said to be directly reachable from cell if and only if is one of these 4 cells { , , and }).
Given the constraint that each cell can be part of at most 1 "nice-quadruple", what's the maximum number of "nice-quadruples" you can select?
Input format
Output format
Output the maximum number of "nice-quadruple" you can select.
Constraints
Let represent the cell in row i and column j.(considering as the top left of the grid.) Then the set of cells {, , ,} form one "nice-quadraple" and the set of cells {, , ,} form another "nice-quadraple". You can verify that you cannot get more than 2 "nice-quadraple" .