CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #923 #925 →

#924. Number of islands

You get a map made of `1` (land) and `0` (water). Count the islands (land cells connected in 4 directions). ### Input n m, then n lines. ### Output A number.

Examples

Input
6 6
100010
001100
011110
110101
001101
000001
Output
4
Input
5 6
101101
111111
100110
100011
000101
Output
2

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!