def count_trees(data, x_inc, y_inc):
    """Count trees in input data."""
    max_length, max_height, x, y, trees = len(data[0]), len(data), 0, 0, 0
    limit_reached = False
    while not limit_reached:
        x += x_inc
        y += y_inc
        if x >= max_length:
            x -= max_length
        if data[y][x] == "#":
            trees += 1
        if y + y_inc >= max_height:
            limit_reached = True
    return trees