public static int dfs(char[][] grid) {
    int count = 0;
    for (int i = 0; i < grid.length; i++) {
      for (int j = 0; j < grid[i].length; j++) {
        if ('1' == grid[i][j]) {
          count = count + 1;
          cdfs(grid, i, j); 
        }
      }
    }
    return count;
  }