Measurement of the inelastic cross section in proton-lead collisions at a centre-of-mass energy per nucleon pair of 5.02 TeV