---
# System prepended metadata

title: 2315. Count Asterisks
tags: [Leetcode, Easy]

---

# 2315. Count Asterisks
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/count-asterisks/description/
## Code
```java=
class Solution {
    public int countAsterisks(String s) {
        int cnt = 0;
        boolean inPair = false;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='|') inPair = !inPair;
            if(!inPair && s.charAt(i)=='*') cnt++;
        }
        return cnt;
    }
}
```