functions that find the minmum number n, which makes n*m only contains ones or zeros