After playing around with the ASCII Art program you made, legolover2 wonders…
If you were to only use the draw dot and change colour commands, what is the least number of operations required to recreate a drawing?
To refresh your memory, the draw dot operation draws a single character at the specified coordinate (anywhere you want). The change colour operation changes the colour, or character that operations use. The default colour is
.. The canvas is initially blank (filled with
The first line will contain two space separated integers, ~C~ ~R~ ~(1 \le C, R \le 100)~, the number of columns and rows of the drawing.
The next ~R~ lines will contain ~C~ characters. Note that the character may be a space.
Output a single integer, the minimum number of operations.
Sample Input 1
5 3 .|... .| . .+--.
Sample Output 1
Explanation for Sample Output 1
Using the default colour, draw the 8 outer dots.
. ... . . . .
Then change the colour and draw the column (1 colour change + 2 draw dots)
.|... .| . . .
Then change the colour and draw the cross (1 colour change + 1 draw dot)
.|... .| . .+ .
Then change the colour and draw the horizontal line (1 colour change and 2 draw dots)
.|... .| . .+--.
That is ~1 + 1 + 1~ colour changes + ~(8 + 2 + 1 + 2 = 13)~ draw dots for a total of ~16~ operations.
Sample Input 2
11 6 / / / , xxxxxxxx x O >->-xx- x >->->-x XX XxX Xx` XXX XXX
Sample Output 2