EAN = "123456789041"

def eanCheck(ean):
    checksum = 0
    for i, digit in enumerate(reversed(ean)):
        checksum += int(digit) * 3 if (i % 2 == 0) else int(digit)
    
    return (10 - (checksum % 10)) % 10

print "Digito de control: %d" %eanCheck(EAN)