#C315. Count Asterisks Not Between Vertical Bars

    ID: 46545 Type: Default 1000ms 256MiB

Count Asterisks Not Between Vertical Bars

Count Asterisks Not Between Vertical Bars

You are given a string s consisting of asterisks (*) and vertical bars (|). The vertical bars act as delimiters that toggle the state of counting. When you encounter a vertical bar, the state switches between "inside" and "outside" a pair of bars. Your task is to count the number of asterisks that are not enclosed between a pair of vertical bars.

More formally, let \(s\) be the given string and let the function count_asterisks(s) be defined as follows:

$$ \text{result} = \sum_{i \in \{\text{positions of } '*'\} \atop {\text{not enclosed within } '|'}} 1. $$

Note that every occurrence of | toggles the state of whether you are currently inside or outside of a barred section. It is guaranteed that the string is well-formed with respect to vertical bars.

inputFormat

The input consists of a single line containing a string s composed of characters including asterisks (*) and vertical bars (|).

outputFormat

Output a single integer representing the number of asterisks in the string that are not enclosed between vertical bars.

## sample
l|*e*et|c*o|*de|
1

</p>