a=gets.to_i if a==0 p -1 exit end 1.upto(100){|i| if a/i==1 && a%i==7 p i exit end } p -1