def luhn_checksum(number, chars=DIGITS):
    '''
    Calculates the Luhn checksum for `number`

    :param number: string or int
    :param chars: string

    >>> luhn_checksum(1234)
    4

    '''
    length = len(chars)
    number = [chars.index(n) for n in reversed(str(number))]
    return (
        sum(number[::2]) +
        sum(sum(divmod(i * 2, length)) for i in number[1::2])
    ) % length