combine from 0 - S.size()