def parse_imsi(imsi):
    """This method verifies that the input is a valid imsi,
    ie. it is 14 or 15 digits. It will also strip the prefix "IMSI".
    """
    imsi = imsi[4:] if 'IMSI' in imsi else imsi
    if not str(imsi).isdecimal():
        raise TypeError('IMSI not decimal: %s' % imsi)
    if len(str(imsi)) not in [14, 15]:
        raise ValueError('len(IMSI) invalid')
    return imsi