SELECT ( COUNT( * ) AS ?count ) WHERE { ?s ?p ?o . } GROUP BY ( ! ?s ) ( - ?o ) ( "a" ) ( ?s + ?o )