How do I count the occurrence of a given character in a string? You are given a string S and you have to count how many subsequences of this string do not have the same characters at adjacent positions. Can the subsequence of string S be obtained from deleting zero, or more characters from string S?