import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1)

if __name__ == '__main__':
    main() import sys sys def IS(): return sys.stdin.readline().rstrip() IS def II(): return int(IS()) II def MII(): return list(map(int, IS().split())) MII def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================# MIIZ def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1) main k = II() k II() II sevens = 7%k sevens 7%k 7 k for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
     i range(1, k+1) range 1 k+1 k 1 if sevens % k == 0:
            print(i)
            return
         sevens % k == 0 sevens % k sevens k 0 print(i) print i return sevens = (10*sevens + 7)%k sevens (10*sevens + 7)%k 10*sevens + 7 10*sevens 10 sevens 7 k print(-1) print -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def IS(): return sys.stdin.readline().rstrip() def IS(): return sys.stdin.readline().rstrip() IS def MII(): return list(map(int, IS().split())) def MII(): return list(map(int, IS().split())) MII def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================# def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================# MIIZ def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1) def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1) main def II(): return int(IS()) def II(): return int(IS()) II
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1)

if __name__ == '__main__':
    main()