#!/usr/bin/env python3


def main():
    k = int(input())
    num = 0
    soeji = 0
    ar = [0 for _ in range(k)]

    while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

    print(-1 if ar[0] == 0 else ar[0])


if __name__ == '__main__':
    main() def main():
    k = int(input())
    num = 0
    soeji = 0
    ar = [0 for _ in range(k)]

    while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

    print(-1 if ar[0] == 0 else ar[0]) main k = int(input()) k int(input()) int input() input num = 0 num 0 soeji = 0 soeji 0 0 for _ in range(k) for _ in range(k) _ range(k) range k for _ in range(k) 0 ar = [0 for _ in range(k)] ar [0 for _ in range(k)] while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

     True if ar[soeji] > 0:
            break
         ar[soeji] > 0 ar[soeji] ar soeji 0 break ar[soeji] = num ar[soeji] ar soeji num soeji = (soeji * 10 + 7) % k soeji (soeji * 10 + 7) % k soeji * 10 + 7 soeji * 10 soeji 10 7 k num += 1 num 1 print(-1 if ar[0] == 0 else ar[0]) print -1 if ar[0] == 0 else ar[0] ar[0] == 0 ar[0] ar 0 0 -1 ar[0] ar 0 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    k = int(input())
    num = 0
    soeji = 0
    ar = [0 for _ in range(k)]

    while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

    print(-1 if ar[0] == 0 else ar[0]) def main():
    k = int(input())
    num = 0
    soeji = 0
    ar = [0 for _ in range(k)]

    while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

    print(-1 if ar[0] == 0 else ar[0]) main
#!/usr/bin/env python3


def main():
    k = int(input())
    num = 0
    soeji = 0
    ar = [0 for _ in range(k)]

    while True:
        # print(soeji)
        if ar[soeji] > 0:
            break
        ar[soeji] = num
        soeji = (soeji * 10 + 7) % k
        num += 1

    print(-1 if ar[0] == 0 else ar[0])


if __name__ == '__main__':
    main()
