Was a male spouse of M2 a writer of M0
SELECT count(*) WHERE {
?x0 ns:film.writer.film M0 .
?x0 ns:people.person.gender ns:m.05zppz .
?x0 ns:people.person.spouse_s/ns:people.marriage.spouse|ns:fictional_universe.fictional_character.married_to/ns:fictional_universe.marriage_of_fictional_characters.spouses M2 .
FILTER ( ?x0 != M2 )
}