solve substring divisibility