def str_to_int(s):
    """ Takes a string provided through user input, which may be hexadecimal or an integer, and
        converts it to the actual corresponding integer.  """
    s = s.strip().lower()
    if s.startswith("$"):
        return int(s[1:], 16)
    elif s.startswith("0x"):
        return int(s[2:], 16)
    else:
        return int(s)