#include <iostream>
using namespace std;
int main(){
  long long k; cin >> k;
  long long r=7;
  long c=1;
  while(c<=1000000){
    r=r%k;
    if(r==0){
      cout << c << endl;
      return 0;
    }
    r=10*r+7;
    c++;
  }
  cout << -1 << endl;
}