def count_collisions(right: int, down: int, aoc_map: list) -> int:
    """
    Given the trajectory, count the number of collisions (or close shaves) with trees.
    :param right: The number of spaces to the right moved in one time tick.
    :param down: The number of spaces down moved in one time tick.
    :param aoc_map: The map of the hill
    :return: The number of times one will encounter a tree on the way down.
    """
    map_length = len(aoc_map[0])
    map_height = len(aoc_map)

    count = 0
    j = right
    for i in range(down, map_height, down):
        j %= map_length
        if aoc_map[i][j] == "#":
            count += 1
        j += right

    return count