a=gets.to_i 8.upto(100){|i|break(puts(i)) if a.to_s(i)=='17'}&&p(-1)