You learned the filtering pattern: count items that satisfy a condition. This pattern appears everywhere in programming. The approach is identifying the condition before writing code. You also saw that not all problems need arrays.
When you process items independently and only need a count, you can work with one item at a time. This saves memory and simplifies your code. The read-check-count pattern is your friend.
Read the values, apply your condition, update the counter. Three steps that solve countless problems.