def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1)

if __name__ == '__main__':
    main() def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1) main k = int(input()) k int(input()) int input() input a = [1] a [1] 1 a.append(7 % k) a.append a append 7 % k 7 k a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1) for i in range(2, k+1) i range(2, k+1) range 2 k+1 k 1 for i in range(2, k+1) a.append((a[i-1] * 10 + 7) % k) a.append a append (a[i-1] * 10 + 7) % k a[i-1] * 10 + 7 a[i-1] * 10 a[i-1] a i-1 i 1 10 7 k [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)] for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
     i range(1, k+1) range 1 k+1 k 1 if a[i] == 0:
            print(i)
            return
     a[i] == 0 a[i] a i 0 print(i) print i return print(-1) print -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1) def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1) main
def main():
    k = int(input())
    a = [1]
    a.append(7 % k)
    [a.append((a[i-1] * 10 + 7) % k) for i in range(2, k+1)]
    for i in range(1, k+1):
        if a[i] == 0:
            print(i)
            return
    print(-1)

if __name__ == '__main__':
    main()
