A grid of 1 (land) and 0 (water) is given. An island is a group of land cells connected horizontally or vertically. Count the islands.
1
0
Input: each line is one grid row (characters 0/1, no spaces). Output: the number of islands.
Your program reads from stdin and prints to stdout.
Example 1
Input: 11110 11010 11000 00000
Output: 1
Hints