import re


def formula_to_composition(formula):
    """
    Breaks a molecular formula into its constituent elements.  Returns a
    dictionary of element keys and an integer formula
    """
    # Ignore the first value in the split, because it will be blank from
    # trying to split on the first element symbol.
    parts = [re.split('([0-9]+)', test) for test in
    re.findall('[A-Z][a-z]?[0-9]*', formula)]
    values = [int(part[1]) if len(part) > 1 else 1 for part in parts]
    elements = [part[0] for part in parts]
    return {k:int(v) for k, v in zip(elements, values)}