Anagram optimally