# k = gets.chomp.to_i
# # if k % 7 != 0
# #     puts "-1"
# #     exit
# # end
# kai = k 
# i = 1
# kou = 10
# kazu = 1 
# hantei = 9 * kai + 7
# # p hantei
# # if hantei % 7 != 0
# #     puts "-1"
# #     exit
# # end
# # hantei = hantei / 7
# # if hantei % 10 != 0
# #     puts "-1"
# #     exit
# # end

# k = k / 7
# k = k * 9 + 1
# while true
#     if i % (kai / 7) == 0
#         puts kazu
#         break
#     else
#         i = i + kou ** kazu
#         kazu += 1
#     end

# end


# p k

# k = gets.chomp.to_i
# a = 0
# i = 0
# arr = [k+1]
# mod = k+1
# until mod == 0
#     a = 7 + 10 * a #7,77..を書いた
#     mod = a % k
#     if arr.include?(mod) || i == k
#         puts "-1"
#         exit
#     end
#     arr << mod 
#     i += 1
# end
# puts i

k = gets.chomp.to_i
i = 1
a = 7 % k
hazime = a
arr = [-1]
if k != 7
    until a == 0 
        a = (7 + a * 10) % k
        if a == hazime || i == k
            puts arr.shift
            exit
        end
        i += 1
    end
else
    puts "1"
    exit
end
puts i