def num_ancestors(p):
    """
    Returns the number of known ancestors of p

    Does not include p, so the answer might be 0.

    Parameter p: The initial family member
    Precondition: p is a Person (and not None)
    """
    # Work on small data    (BASE CASE)
    if p.mom == None and p.dad == None:
        return 0
    
    # Break up into halves  (RECURSIVE CASE)
    moms = 0
    if not p.mom == None:
        # Do not forget to include mom as well.
        moms = 1+num_ancestors(p.mom)
    
    dads = 0
    if not p.dad == None:
        # Do not forget to include dad as well.
        dads = 1+num_ancestors(p.dad)
    
    # Combine the answer
    return moms+dads