Maths: how to restrict input to specific values