def check_cas_number(cas_no):
    """
	Checks the CAS number to ensure the check digit is valid
	with respect to the rest of the number.
	
	If the CAS number is valid 0 is returned. If there is a problem the difference
	between the computed check digit and that given as part of the CAS number
	is returned.
	
	:param cas_no:
	:type cas_no: int
	:return:
	:rtype: int
	"""
    cas_no = abs(int(cas_no))
    check_digit = cas_no % 10
    main_value = (cas_no - check_digit) // 10
    block_2 = main_value % 100
    block_1 = (main_value - block_2) // 100
    last_digit = block_2 % 10
    check_total = last_digit + (block_2 - last_digit) // 10 * 2
    for position, digit in enumerate(str(block_1)[::-1]):
        check_total += int(digit) * (position + 3)
    if check_digit == check_total % 10:
        return 0
    else:
        return check_total % 10 - check_digit
