A Eugenics research worker is working with two types of bacteria. One type triples in number every ten minutes while the other one becomes 5 times in the same time. If the total number of bacteria after half an hour is 1118, what was the total number at the beginning ?