On the complexity of nonsmooth automatic differentiation