Posts, rails and pickets
sections = fence length ÷ post spacing, rounded up posts = sections + 1 + gates rails = sections × rails per section pickets = fence length (in) ÷ (picket width + gap)
Corners and ends are already counted as posts. Each gate needs a post on each side, so add one post per gate in a straight run.
Setting posts
Dig holes about three times the post width — 10–12″ for a 4×4 — to a third of the post’s exposed height and below the frost line. Put a few inches of gravel in the bottom for drainage, set the post plumb, and fill with concrete sloped away from the post.