#C1498. Count Distinct Adjacent Pairs in a String

    ID: 44688 Type: Default 1000ms 256MiB

Count Distinct Adjacent Pairs in a String

Count Distinct Adjacent Pairs in a String

You are given a non-empty string (S) consisting of lowercase English letters. Your task is to calculate the number of distinct adjacent pairs (substrings of length 2) present in the string. Specifically, if we consider the set ({ S[i!:!i+2] : 0 \leq i < |S| - 1 }), you need to find its size. For example, for (S = \texttt{ababc}), the pairs are (\texttt{ab}), (\texttt{ba}), (\texttt{ab}), and (\texttt{bc}); the distinct pairs are ({ \texttt{ab},, \texttt{ba},, \texttt{bc} }), so the answer is 3.

inputFormat

Input is given from standard input as a single line containing the string (S). The string consists only of lowercase English letters and has a length of at least 1.

outputFormat

Output a single integer denoting the number of distinct adjacent pairs in the string.## sample

ababc
3

</p>