import re


def rlist_to_int(string):
    """Takes an rlist string as input, and outputs a corresponding integer"""

    rlist = 0
    string = re.sub(r"r|R", "", string)
    for m in re.finditer(r"[^,]+", string):
        args = m.group().split("-")
        if len(args) == 1: lo,hi = args*2
        else: lo,hi = args
        rlist |= 2**(int(hi) + 1) - 2**int(lo)
    return rlist