from typing import Union


def to_n_cpus(cpu_str: str) -> Union[int, float]:
    """Convert cpu string to number of cpus
    (e.g. '500m' -> 0.5, '2000000000n' -> 2)
    """
    if cpu_str.endswith("n"):
        return int(cpu_str.strip("n")) / 1000000000
    elif cpu_str.endswith("u"):
        return int(cpu_str.strip("u")) / 1000000
    elif cpu_str.endswith("m"):
        return int(cpu_str.strip("m")) / 1000
    elif cpu_str.isnumeric():
        return int(cpu_str)
    else:
        return 0