The answer is 3 because:
The cyclomatic complexity of any structured program with only one entrance point and one exit point is equal to the number of decision points (i.e., "if" statements or conditional loops) contained in that program plus one. However, this is true only for decision points counted at the lowest, machine-level instructions. Decisions involving compound predicates like those found in high-level languages like IF cond1 AND cond2 THEN ... should be counted in terms of predicate variables involved, i.e. in this examples one should count two decision points, because at machine level it is equivalent to IF cond1 THEN IF cond2 THEN ....
Cyclomatic complexity may be extended to a program with multiple exit points; in this case it is equal to:
π − s + 2,
where π is the number of decision points in the program, and s is the number of exit points.
Source: Wikepedia