Healthy Pet Animals Count


- Naveen
- Karthik

Problem Statement


              There are N pet animals arranged in R rows and C columns. The
              cells which contain pet animals are marked with the value 1. There
              are certain pet animals infected by a contagious disease and they
              are marked by -1 (that is instead of 1, they will be denoted by
              -1). The disease will spread to any adjacent animals (left, right,
              top, bottom, top-left, top-right, bottom-left, bottom-right)
              infecting them too. The program must print the final count H of
              pet animals which are not infected.
            
            

Input Format

The first line contains R and C separated by a space. The next R lines, each containing C columns indicating the details.

Example

Input:
1 0 1 0 -1
1 0 0 0 1
0 0 1 1 0
1 0 1 0 0
Output:
4

Explanation

Blue: Healthy
Red: Infected

Code

Using DFS algorithm.

Explanation