def check_neighbors(x, y, grid):
    """
    check the count of neighbors
    :param x: row of live cell
    :param y: col of live cell
    :param grid: grid at the time
    :return: number of neighbors
    """
    neighbors = 0
    c_y = [-1, -1, -1, 1, 1, 1, 0, 0]
    c_x = [-1, 1, 0, -1, 1, 0, -1, 1]
    for n in range(0, 8):
        if grid[(c_y[n]+y) % 8][(c_x[n]+x) % 8] > 0:
            neighbors += 1
    return neighbors