# Original solution
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    k = int(eval(input()))
    if k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8 or k % 10 == 0:
        print((-1))
        exit()
    elif k % 10 == 1:
        tmp = k * 7
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            if tmp // 10 % 10 <= 7:
                num = 7 - tmp // 10 % 10
            else:
                num = tmp // 10 % 10 - 7
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
    elif k % 10 == 3:
        tmp = k * 9
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) * 3 - 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
    elif k % 10 == 7:
        tmp = k * 1
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) * 7 + 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
    elif k % 10 == 9:
        tmp = k * 3
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) + 3) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
            """
                num = 7
            elif 10 - (tmp // 10) % 10 == 3:
                num = 9
            elif 10 - (tmp // 10) % 10 == 7:
                num = 1
                print(tmp)
            elif 10 - (tmp // 10) % 10 == 9:
                num = 3
            else:
                print(-1)
                break
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            print(tmp)
            ans += 1
            """


if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    k = int(eval(input()))
    if k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8 or k % 10 == 0:
        print((-1))
        exit()
    elif k % 10 == 1:
        tmp = k * 7
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            if tmp // 10 % 10 <= 7:
                num = 7 - tmp // 10 % 10
            elif tmp // 10 % 10 == 8:
                num = 9
            elif tmp // 10 % 10 == 9:
                num = 8
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 8:
                print((-1))
                break
    elif k % 10 == 3:
        tmp = k * 9
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) * 3 - 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 5 * 10 ** 7:
                print((-1))
                break
    elif k % 10 == 7:
        tmp = k * 1
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) * 7 + 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 8:
                print((-1))
                break
    elif k % 10 == 9:
        tmp = k * 3
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print((ans + len(str(tmp)) - 1))
                break
            num = ((tmp // 10 % 10) + 3) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 8:
                print((-1))
                break

if __name__ == '__main__':
    main()