IntermediateRating 1200
Island Coastline
A grid of 1 (land) and 0 (water) has exactly one island. Print its perimeter.
Input
r c, then r lines.
Output
A number.
Sample 1
Input
4 4 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 0
Output
16
Sample 2
Input
1 1 1
Output
4
Output appears here