#include <bits/stdc++.h>
using namespace std;

int main() {
  int k; cin>>k;
  if(k%2==0 || k%5==0) {
    cout<<"-1\n";return 0;
  }
  int x=7%k, c=1;
  while(x != 0) {
    x = (x*10) +7;
    x %= k;
    c++;
  }
  cout<<c<<"\n";
}