Finding Rank of a word - Prepare for Exams