You can do all these types of problems using Venn diagrams to see what's going on. For the first problem, the circle for A has 12 members; the intersection portion of it has 5 members (that means, the non-intersection portion of A has 12-5=7 members). Also, for B, its circle has 14 members, of which 5 are in the intersection, leaving 14-5=9 members outside the intersection overlap. Put those three groups together: 7 + 5 + 9 = ?
Similar reasoning for the second problem, also. Draw the two intersecting circles for A and B, then use the given data to sequentially figure the sizes of (i.e number of members in) each portion.