Divide the carton quantity by cartons per pallet and round up. The remainder is a short last pallet.
The last pallet when the quantity is not an exact multiple of cartons per pallet. It is still a handling unit if you ship it.
Cartons per layer on the deck you will ship. Height and weight come next.
Open the pallet calculator, choose 48x40 or 1,200x800, and enter the carton and the caps.
Cartons per layer times layers, after the weight cap.
Floor of deck length over carton side, times floor of deck width over the other side. Repeat with the carton turned and keep the larger result.