CountDiv solution