import base64


def parse_workchain(smc_address: str) -> int:
    """Parse workchain https://ton.org/docs/#/howto/step-by-step"""
    decoded_addr = base64.urlsafe_b64decode(smc_address)
    worckchain_signed_8 = decoded_addr[1]
    worckchain_signed_8 = (((worckchain_signed_8 >> 7) * 128) ^ worckchain_signed_8) - (
            (worckchain_signed_8 >> 7) * 128)
    return worckchain_signed_8