Finding the shaded area in grids