MDX Count() counts how many items in a set. If you insist to use Count(), you have to build a dimension which groups all 23 item under parent 23 grouping, etc
Then define custom rollup formula on 23 grouping as Count
The simple approach will be to build a table in relational database(pre-solving the count