solve safety numbers problem