Two Sequences One Tree

A binary tree with distinct integer keys produces these two traversals:

traversal sequence
preorder 20, 8, 4, 2, 6, 14, 30, 25, 40
inorder 2, 4, 6, 8, 14, 20, 25, 30, 40

Rebuild the tree. How many leaves does it have?

A

6

B

3

C

4

D

5