def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod)


if __name__ == '__main__':
    main() def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod) main K = int(input()) K int(input()) int input() input mod = 7 % K mod 7 % K 7 K mods = set([mod]) mods set([mod]) set [mod] mod if mod == 0:
        print(1)
        exit()
     mod == 0 mod 0 print(1) print 1 exit() exit ans = 1 ans 1 while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod) True ans += 1 ans 1 mod = (mod * 10 + 7) % K mod (mod * 10 + 7) % K mod * 10 + 7 mod * 10 mod 10 7 K if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod) mod == 0 mod 0 print(ans) print ans exit() exit elif mod in mods:
            print(-1)
            exit()
         mod in mods mod mods print(-1) print -1 exit() exit mods.add(mod) mods.add mods add mod if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod) def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod) main
def main():
    K = int(input())
    mod = 7 % K
    mods = set([mod])
    if mod == 0:
        print(1)
        exit()
    ans = 1
    while True:
        ans += 1
        mod = (mod * 10 + 7) % K
        if mod == 0:
            print(ans)
            exit()
        elif mod in mods:
            print(-1)
            exit()
        else:
            mods.add(mod)


if __name__ == '__main__':
    main()
