def collisions(grid_map, rise, run):
    """
    Count the number of trees (represented by `#`) encountered by moving along the path 
    (i * rise, i * run) through the grid starting from i = 0 (at (0,0)) to i = height - 1.
    """
    period = len(grid_map[0])
    return sum(row[i * run % period] == '#' for i, row in enumerate(grid_map[::rise]))