spoj SUBS - String it out

how to solve this?

//