문제
Art critics worldwide have only recently begun to recognize the creative genius behind the great bovine painter, Picowso.
Picowso paints in a very particular way. She starts with an
2 2 2 0
2 2 2 0
2 2 2 0
0 0 0 0She might then paint a rectangle in color 7:
2 2 2 0
2 7 7 7
2 7 7 7
0 0 0 0And then she might paint a small rectangle in color 3:
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0Each rectangle has sides parallel to the edges of the canvas, and a rectangle could be as large as the entire canvas or as small as a single cell. Each color from
Given the final state of the canvas, please count how many of the
.
Problem credits: Brian Dean
입력
The first line of input contains
출력
Please output a count of the number of colors that could have been drawn first.
예제
4
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0
14
In this example, color 2 could have been the first to be painted. Color 3 clearly had to have been painted after color 7, and color 7 clearly had to have been painted after color 2. Since we don't see the other colors, we deduce that they also could have been painted first.