      MODULE judgePrimeMod
!入力値が素数か否かを判定するためのモジュール．
      implicit none
      integer,parameter,private :: p = 16
      
      contains
      function isPrime( x ) result( TorF )
        implicit none
        integer(p),intent(in) :: x
        logical :: TorF
        integer(p) :: i
        
        if( x==2 )then
          TorF = .true.
          return
        end if
        
        if( x<2 .or. mod(x,2)==0 )then
          TorF = .false.
          return
        end if
        
        i = 3
        do while( i<=ceiling( sqrt(real(x)) ) )
          
          if( mod(x,i)==0 )then
            TorF = .false.
            return
          end if
          
          i = i + 2
        end do
        
        TorF = .true.
      end function
      END MODULE judgePrimeMod
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      PROGRAM Repsept
      use judgePrimeMod
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: k,i,seven=0,ten
      
      
      read*,k
      if( mod(k,2)==0 .or.mod(k,5)==0 )then
        print'(a)','-1'
        stop
      end if
      
      i = 0
      ten = 1
      do while( .true. )
        seven = seven + 7*ten
        seven = mod(seven,k)
        
        if( mod(seven,k)==0 )then
          exit
        else
          i = i+1
          ten = mod(ten*10,k)
        end if
      end do
      
      print*,i+1
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM