Secret Rooms of the Ternopil Castle
On the shore of the picturesque Ternopil Lake stands a castle. Although it appears grand, it surprisingly contains only a few small rooms. Historians, intrigued by the ancient blueprints of the castle, discovered a map showing numerous rooms, all lacking doors and windows. This led them to wonder: how many rooms does the Ternopil Castle actually have?
Input
The first line provides two natural numbers: N (3 ≤ N ≤ 1000), representing the length of the map, and M (3 ≤ M ≤ 1000), representing the width of the map. This is followed by N lines, each containing M characters. The character "1" denotes a section of the wall, while "0" indicates a part of a room. All outer elements of the map are guaranteed to be "1". Two room elements "0" are considered adjacent and part of the same room if they share a common side.
Output
Output a single number indicating the total number of rooms on the discovered map.