from typing import IO
from typing import Tuple
from typing import Optional


def solve_task(input_io: IO, slope: Tuple[int, int]) -> int:
    """
    Solves task 1: number of trees for slope right 3 down 1.

    Parameters
    ----------
    input_io: IO
        Map stream.

    slope: (slope_right: int, slope_down: int)
        Slope to use from top to botton.


    Returns
    -------
    int
        Number of trees '#' in path from top to bottom.
    """

    def go_down(amount: int) -> Optional[str]:
        """Try to advance amount lines 'down' in the map stream."""
        line = None
        while (amount > 0) and (line := input_io.readline()):
            amount -= 1
        return line

    trees = 0
    slope_right, slope_down = slope
    fline = input_io.readline().strip()
    assert fline[0] == "."
    columns = len(fline)
    current_column = 0
    while line := go_down(slope_down):
        line = line.strip()
        current_column += slope_right
        current_column %= columns
        trees += line[current_column] == "#"
    input_io.seek(0)
    return trees