Fence length and post spacing
There is a post at each end. Line posts follow your spacing, and a leftover span shorter than the spacing still gets an end post. Sections are ceil(length ÷ spacing). When length divides evenly by the spacing, posts equal floor(length ÷ spacing)+1; otherwise one more post is added at the far end. Gate openings are subtracted from the length that needs boards, and each gate adds one extra post (a post on each side of the opening, one of which is already counted in the remaining run). This is a geometry estimate, not a lumber or fence product shelf.
This is an estimate. Slope, corners, and how you cut the boards will change the real count.