import re


def get_sale_head(line):
    """Return the total number of head sold at the sale.
    If present, the number is usually at the top of the market report."""
    
    for this_line in line:
        match = re.search(r'([0-9,]+)\s*(head|cattle)?.*sold', this_line, re.IGNORECASE)
        if match:
            return match.group(1).replace(',', '')