The maths of rioting