#C8959. Count Palindromic Words
Count Palindromic Words
Count Palindromic Words
You are given a single line containing a series of words separated by spaces. Your task is to count how many of these words are palindromes. A word is considered a palindrome if it reads the same backwards and forwards, ignoring case. For example, the word "Madam" is a palindrome because, when converted to lowercase, it becomes "madam", which reads the same backward.
Note: All words are separated by whitespace, and the checking is case-insensitive.
Examples:
- Input:
madam racecar noon
Output:3
- Input:
Hello world
Output:0
Your solution should read input from stdin
and output the result to stdout
.
inputFormat
The input consists of a single line containing a sentence. The sentence contains words separated by spaces.
Input is read from standard input (stdin).
outputFormat
The output should be a single integer representing the number of palindromic words in the input sentence. This should be printed to standard output (stdout).
## samplemadam racecar noon
3