from random import randint
def simul(n):
    total = ...
    for k in range(...):
        D = ...
        if D ... :
            total = ...
    return total
