#K62387. Distinct Palindromic Substrings of Length 3
Distinct Palindromic Substrings of Length 3
Distinct Palindromic Substrings of Length 3
Given a string s, your task is to determine the number of distinct substrings of length 3 that are palindromes. A substring of length 3 is considered a palindrome if it reads the same forwards and backwards. Formally, for any substring t of length 3, it is a palindrome if:
\( t_1 = t_3 \)
where \( t_1 \) and \( t_3 \) are its first and third characters respectively. Only count each distinct palindromic substring once.
For example, in the string "ababa", the substrings "aba" and "bab" are palindromes, so the answer is 2.
inputFormat
The input consists of a single line containing a string s composed of lowercase English letters. The length of s does not exceed 105.
outputFormat
Output a single integer representing the number of distinct palindromic substrings of length 3 found in s.
## sampleabcdef
0
</p>