A string A contains k lowercase letters and can form multiple subsequences (not necessarily contiguous). If each lowercase letter appears with the same frequency in a subsequence as in the original string, then this subsequence is considered a perfect subsequence. Given a string A, determine the number of its perfect subsequences. For example, in the string "abca", the subsequences "a", "b", "c", "a", "ab", "bc", "ca", "aa", etc., are all valid.
Check out your Company Bowl for anonymous work chats.