from typing import Union
from typing import List


def count(obj: Union[int, List]) -> int:
    """Return the number of integers in obj.

    >>> count(27)
    1
    >>> count([4, 1, 8])
    3
    >>> count([4])
    1
    >>> count([])
    0
    >>> count([4, [1, 2, 3], 8])
    5
    >>> count([1, [2, 3], [4, 5, [6, 7], 8]])
    8
    """
    if isinstance(obj, int):
        return 1
    else:
        return sum(count(i) for i in obj)

    # if isinstance(obj, int):
    #     return 1
    # else:
    #     s = 0
    #     for lst_i in obj:
    #         s += count(lst_i)
    #     return s