A pencil box in the shape of a rectangular prism measures 3 inches by 4 inches by 12 inches. What is the length of the longest pencil that can fit in the box? Explain your answer.