James had a box of pens. He removed 1/6 of the pens and then replaced 4 pens. Next, he removed 1/4 of the remaining pens and then replaced 3 pens. Finally, he removed 1/3 of the pens that were left and replaced 2 pens. He had 46 pens in the end. How many pens did James have at first?