def run(text: str, value: int) -> int:
    """ Runs the assembly code directly with the given digits as input, and returns the value in z """
    memory = [0, 0, 0, 0]  # w x y z
    indexes = {'w': 0, 'x': 1, 'y': 2, 'z': 3}

    def ref(p):
        if p in indexes:
            return memory[indexes[p]]
        return int(p)

    digits = list(map(int, str(value)))  # Handy trick to convert base 10 int to msb -> lsb digits
    for instruction in text.split('\n'):
        parts = instruction.split(' ')
        if parts[0] == 'inp':
            memory[indexes[parts[1]]] = digits.pop(0)
        elif parts[0] == 'add':
            memory[indexes[parts[1]]] += ref(parts[2])
        elif parts[0] == 'mul':
            memory[indexes[parts[1]]] *= ref(parts[2])
        elif parts[0] == 'div':
            memory[indexes[parts[1]]] //= ref(parts[2])
        elif parts[0] == 'mod':
            memory[indexes[parts[1]]] %= ref(parts[2])
        elif parts[0] == 'eql':
            memory[indexes[parts[1]]] = 1 if ref(parts[2]) == ref(parts[1]) else 0

    return memory[3]