#K91307. Minimum Cost to Convert Stars to Hashes
Minimum Cost to Convert Stars to Hashes
Minimum Cost to Convert Stars to Hashes
You are given a string s that consists solely of the characters '*'
and '#'
. Your task is to determine the minimum cost to convert all '*'
characters into '#'
characters. Each conversion of a '*'
to a '#'
incurs a cost of 1. Therefore, if there are N occurrences of '*'
in the string, the total cost will be \(cost = N\).
Your program should read the input string from stdin and output the computed cost to stdout.
inputFormat
A single line containing a non-empty string s composed only of the characters '*'
and '#'
.
outputFormat
Output a single integer which represents the minimum cost required to convert all '*'
characters to '#'
in the string.
*#*#
2