#K5761. Count Valid Substrings

    ID: 30459 Type: Default 1000ms 256MiB

Count Valid Substrings

Count Valid Substrings

Given a string ( s ), your task is to count the number of substrings that start and end with the same character. A substring is defined as a contiguous sequence of characters within the string.

For example, if ( s = \texttt{abcab} ), there are 7 substrings that satisfy the condition. Your program should read the input from standard input and output the result to standard output.

inputFormat

Input is a single line containing the string ( s ) (which can be empty).

outputFormat

Output a single integer representing the number of substrings where the first and last characters are the same.## sample

abc
3

</p>