Joshua bought a box if pens. 1 8 of the pens were black 1 4 were blue and 2 5 of the remaining were red. If there were 18 red pens, how many pens did she buy?

Let "x" be the total number of pens Joshua bought.

The number of black pens is 1/8*x
The number of blue pens is 1/4*x
The number of remaining pens is x - (1/8*x) - (1/4*x)
The number of red pens is 18 = (2/5)(x - (1/8*x) - (1/4*x))
18 = (2/5)(x - (1/8*x) - (1/4*x))
18 = (2/5)((13/8)*x)
18 = (26/40)*x
18(40/26) = x
28 = x
Joshua bought 28 pens. Answer: \boxed{28}.