You will be given a map of Soteholm as an N×M grid. Each square in the grid has a side length of 1 km and is either water or land. Your goal is to compute the total length of sea coast of all islands. Sea coast is all borders between land and sea, and sea is any water connected to an edge of the map only through water. Two squares are connected if they share an edge. You may assume that the map is surrounded by sea. Lakes and islands in lakes are not contributing to the sea coast.
Figure 1: Gray squares are land and white squares are water. The thick black line is the sea coast. This example corresponds to Sample Input.
Input:
The first line of the input contains two space separated integers N and M where 1 ≤ N, M ≤ 1000. The follo