If exists then multiply the number of ways and decrement the frequency
if ( freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] ) : NEW_LINE INDENT ways = ways * freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] NEW_LINE freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] -= 1 NEW_LINE DEDENT