k = gets.chomp!.to_i
LS = []
def sevens(s, k, count)
    if s%k == 0
        return count
    else
        LS << s%k
        
        
        count += 1
        s = "7" * count
        s = s.to_i
        sevens(s, k, count)
    end
end

# countを事前に決めてしまう

def make_s(s, k)
    if s < k
        s = (s.to_s + "7").to_i
        make_s(s, k)
    else
        return s
    end
end

s = 7
s = make_s(s, k)
count = s.to_s.length



if k%2 == 0
    puts "-1"
else  
    puts sevens(s, k, count)
end