def METHOD_NAME(mem_spec: str) -> int:
    if len(mem_spec) > 2 and mem_spec[-2:] in k8s_memory_factors:
        return int(mem_spec[:-2]) * k8s_memory_factors[mem_spec[-2:]]
    if len(mem_spec) > 1 and mem_spec[-1] in k8s_memory_factors:
        return int(mem_spec[:-1]) * k8s_memory_factors[mem_spec[-1]]
    raise Exception("number of bytes could not be extracted from memory spec: " + mem_spec)