```ts
function cellCount(grid: number[][], value: number): number {
  if (grid.length === 0) return 0;

  const rows = grid.filter(row => row.length !== 0);
  if (rows.length === 0) return 0;

  const cellCount = rows.reduce((acc, row) => acc + row.filter(cell => cell === value).length, 0);

  return cellCount;
}
```