Problem A
Coast Length
The island municipality of Soteholm is required to write a plan of action for their work with emission of greenhouse gases. They realize that a natural first step is to decide whether they are for or against global warming. For this purpose they have read the IPCC report on climate change and found out that the largest effect on their municipality could be the rising sea level.
The residents of Soteholm value their coast highly and therefore want to maximize its total length. For them to be able to make an informed decision on their position in the issue of global warming, you have to help them find out whether their coastal line will shrink or expand if the sea level rises. From height maps they have figured out what parts of their islands will be covered by water, under the different scenarios described in the IPCC report, but they need your help to calculate the length of the coastal lines.
Task
You will be given a map of Soteholm as an

Input
The first line of the input contains two space separated
integers
Output
Output one line with one integer, the total length of the coast in km.
Sample Input 1 | Sample Output 1 |
---|---|
5 6 011110 010110 111000 000010 000000 |
20 |