Were M2 and M4 written by a person 's spouse , written by M0 's actor , and produced by M3
SELECT count(*) WHERE {
?x0 ns:film.actor.film/ns:film.performance.character M0 .
?x1 ns:people.person.spouse_s/ns:people.marriage.spouse|ns:fictional_universe.fictional_character.married_to/ns:fictional_universe.marriage_of_fictional_characters.spouses ?x2 .
?x2 a ns:people.person .
FILTER ( ?x1 != ?x2 ) .
M2 ns:film.film.produced_by|ns:film.film.production_companies M3 .
M2 ns:film.film.written_by ?x0 .
M2 ns:film.film.written_by ?x1 .
M4 ns:film.film.produced_by|ns:film.film.production_companies M3 .
M4 ns:film.film.written_by ?x0 .
M4 ns:film.film.written_by ?x1
}