rank of a string problem