SELECT *
FROM
(SELECT id FROM A UNION SELECT id FROM B) AS AB
NATURAL LEFT OUTER JOIN
(SELECT id, count(id) AS ca FROM A GROUP BY id) AS AA
NATURAL LEFT OUTER JOIN
(SELECT id, count(id) AS cb FROM B GROUP BY id) AS BB
WHERE coalesce(ca, 0) != coalesce(cb, 0);