Raja sold T-shirts in 3 colours, black, yellow and white. He had 184 more yellow than white shirts. After selling 1/4 of the yellow shirts, he had 87 more yellow than black ones. The number of white shirts was 2/3 of the number of black ones. What was the total number of shirts he had at first?