How many {office held by head of government} are to/by {mayor} ?
How many mayors who were members have there ever been?
How many members held as head of government of the {mayor} ?
SELECT ( COUNT ( ?d ) AS ?k ) { ?d property:office_held_by_head_of_government resource:mayor }
SELECT (COUNT(?sub) AS ?subs ) {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?sub .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P1313> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> http://wikidata.dbpedia.org/resource/Q30185 .
} 

SELECT (COUNT(?sub) AS ?value ) { ?sub wdt:P1313 wd:Q30185 }
1801