Complex sentence: A total of 34 were built but by 2005 only 12 remained on the railway and in use (or under repair).
Split into simpler sentences: A total of 34 were built. By 2005 only 12 remained on the railway and in use (or under repair).