Escherichia coli bacteria respond to DNA damage by a highly orchestrated series of events known as the SOS response, regulated by transcription factors, protein-protein binding, and active protein degradation. We present a dynamical model of the UV-induced SOS response, incorporating mutagenesis by the error-prone polymerase, Pol V. In our model, mutagenesis depends on a combination of two key processes: damage counting by the replication forks and a long-term memory associated with the accumulation of UmuD. Together, these provide a tight regulation of mutagenesis, resulting, we show, in a digital turn-on and turn-off of Pol V. Our model provides a compact view of the topology and design of the SOS network, pinpointing the specific functional role of each of the regulatory processes. In particular, we suggest that the recently observed second peak in the activity of promoters in the SOS regulon (Friedman et al., 2005, PLoS Biology 3(7): e238) is the result of positive feedback from Pol V to RecA filaments.