// codeforces.h : включаемый файл для стандартных системных включаемых файлов
// или включаемые файлы для конкретного проекта.

#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

typedef long long ll;

const string INPUT_FILE = "../../../../codeforces/input.txt";
const string OUTPUT_FILE = "../../../../out/output.txt";

#define PI 3.14159265

// template {{{
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

namespace __input {
	template<class T1, class T2> void re(pair<T1, T2>& p);
	template<class T> void re(vector<T>& a);
	template<class T, size_t SZ> void re(array<T, SZ>& a);

	template<class T> void re(T& x) { cin >> x; }
	void re(double& x) { string t; re(t); x = stod(t); }
	template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
		re(first); re(rest...);
	}

	template<class T1, class T2> void re(pair<T1, T2>& p) { re(p.f, p.s); }
	template<class T> void re(vector<T>& a) { F0R(i, sz(a)) re(a[i]); }
	template<class T, size_t SZ> void re(array<T, SZ>& a) { F0R(i, SZ) re(a[i]); }
}
using namespace __input;

namespace __output {
	template<class T1, class T2> void pr(const pair<T1, T2>& x);
	template<class T, size_t SZ> void pr(const array<T, SZ>& x);
	template<class T> void pr(const vector<T>& x);
	template<class T> void pr(const set<T>& x);
	template<class T1, class T2> void pr(const map<T1, T2>& x);

	template<class T> void pr(const T& x) { cout << x; }
	template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
		pr(first); pr(rest...);
	}

	template<class T1, class T2> void pr(const pair<T1, T2>& x) {
		pr("{", x.f, ", ", x.s, "}");
	}
	template<class T, bool pretty = true> void prContain(const T& x) {
		if (pretty) pr("{");
		bool fst = 1; for (const auto& a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
		if (pretty) pr("}");
	}
	template<class T> void pc(const T& x) { prContain<T, false>(x); pr("\n"); }
	template<class T, size_t SZ> void pr(const array<T, SZ>& x) { prContain(x); }
	template<class T> void pr(const vector<T>& x) { prContain(x); }
	template<class T> void pr(const set<T>& x) { prContain(x); }
	template<class T1, class T2> void pr(const map<T1, T2>& x) { prContain(x); }

	void ps() { pr("\n"); }
	template<class Arg> void ps(const Arg& first) {
		pr(first); ps();
	}
	template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
		pr(first, " "); ps(rest...);
	}
}
using namespace __output;

#define TRACE(x) x
#define __pn(x) pr(#x, " = ")
#define pd(...) __pn((__VA_ARGS__)), ps(__VA_ARGS__), cout << flush

namespace __algorithm {
	template<typename T> void dedup(vector<T>& v) {
		sort(all(v)); v.erase(unique(all(v)), v.end());
	}
	template<typename T> typename vector<T>::const_iterator find(const vector<T>& v, const T& x) {
		auto it = lower_bound(all(v), x); return it != v.end() && *it == x ? it : v.end();
	}
	template<typename T> size_t index(const vector<T>& v, const T& x) {
		auto it = find(v, x); assert(it != v.end() && *it == x); return it - v.begin();
	}

	template<typename T1, typename T2> typename vector<pair<T1, T2>>::iterator lower_bound(
		const vector<pair<T1, T2>>& v, const T1& x) {
		return lower_bound(all(v), x, [](pair<T1, T2> a, pair<T1, T2> b) { return a.f < b.f; });
	}
	template<typename T1, typename T2> typename vector<pair<T1, T2>>::iterator upper_bound(
		const vector<pair<T1, T2>>& v, const T1& x) {
		return upper_bound(all(v), x, [](pair<T1, T2> a, pair<T1, T2> b) { return a.f < b.f; });
	}
}
using namespace __algorithm;

//struct __monostate {
//	friend istream& operator>>(istream& is, const __attribute__((unused))__monostate& ms) { return is; }
//	friend ostream& operator<<(ostream& os, const __attribute__((unused))__monostate& ms) { return os; }
//} ms;

namespace __io {
	void setIn(string s) { freopen(s.c_str(), "r", stdin); }
	void setOut(string s) { freopen(s.c_str(), "w", stdout); }
	void setIO(string s = "") {
		ios_base::sync_with_stdio(0); cin.tie(0);
		cout << setprecision(15);
		if (sz(s)) { setIn(s + ".in"), setOut(s + ".out"); }
	}
}
using namespace __io;
// }}}

// point {{{
template<typename T> struct point {
	T x, y;
	point() : x(0), y(0) {}
	point(T _x, T _y) : x(_x), y(_y) {}
	friend istream& operator >> (istream& i, point& p) { return i >> p.x >> p.y; }
	friend ostream& operator << (ostream& o, const point& p) {
		return o << "(" << p.x << ", " << p.y << ")";
	}

	T norm() const { return x * x + y * y; }
	double len() const { return sqrt(norm()); }
	double ang() const { return atan2(y, x); }
	point<T> conj() const { return { x, -y }; }

	point& operator += (const point& o) { x += o.x; y += o.y; return *this; }
	point& operator -= (const point& o) { x -= o.x; y -= o.y; return *this; }
	point& operator *= (const T& c) { x *= c; y *= c; return *this; }
	point& operator /= (const T& c) { x /= c; y /= c; return *this; }
	friend point operator + (const point& a, const point& b) { return point(a) += b; }
	friend point operator - (const point& a, const point& b) { return point(a) -= b; }
	friend point operator * (const point& a, const T& c) { return point(a) *= c; }
	friend point operator * (const T& c, const point& a) { return point(a) *= c; }
	friend point operator / (const point& a, const T& c) { return point(a) /= c; }

	bool operator == (const point& o) const { return x == o.x && y == o.y; }
	bool operator != (const point& o) const { return x != o.x || y != o.y; }
	bool operator < (const point& o) const { return (x != o.x) ? x < o.x : y < o.y; }
	bool operator > (const point& o) const { return (x != o.x) ? x > o.x : y > o.y; }
	bool operator <= (const point& o) const { return !(*this > o); }

	friend T dot(const point& a, const point& b) { return a.x * b.x + a.y * b.y; }
	friend T cross(const point& a, const point& b) { return a.x * b.y - a.y * b.x; }
	friend T cross(const point& p, const point& a, const point& b) { return cross(a - p, b - p); }

	friend point<T> operator * (const point& a, const point& b) {
		return { a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x };
	}
	friend point<T> operator / (const point& a, const point& b) {
		return a * b.conj() / b.norm();
	}

	point dir() const { return point(*this) / len(); }
	point rotate(const double& ang) const { return *this * point(cos(ang), sin(ang)); }

	T dist(const point& a) const { return (a - *this).len(); }
	T dist(const point& a, const point& b) {
		return abs(cross(*this, a, b)) / a.dist(b);
	}
	point reflect(const point& a, const point& b) const {
		return a + ((*this - a) / (b - a)).conj() * (b - a);
	}
	point foot(const point& a, const point& b) const {
		return (*this + this->reflect(a, b)) / 2;
	}
	friend point extension(const point& a, const point& b, const point& c, const point& d) {
		T x = cross(a, b, c), y = cross(a, b, d);
		return (d * x - c * y) / (x - y);
	}

	friend vector<point> seg_intersect(point a, point b, point c, point d) {
		if (a > b) swap(a, b);
		if (c > d) swap(c, d);

		T a1 = cross(a, b, c), a2 = cross(a, b, d);
		if (a1 > a2) swap(a1, a2);
		if (!(a1 <= 0 && a2 >= 0)) return {};

		if (a1 == 0 && a2 == 0) {
			if (cross(a, c, d) != 0) return {};
			point<T> x1 = max(a, c), x2 = min(b, d);
			if (x1 > x2) return {};
			if (x1 == x2) return { x1 };
			return { x1, x2 };
		}

		point<T> z = extension(a, b, c, d);
		if (a <= z && z <= b) return { z };
		return {};
	}

	using polygon = vector<point<T>>;
	friend ostream& operator << (ostream& o, const polygon& poly) {
		o << "{";
		for (auto pt : poly) o << " " << pt;
		return o << " }";
	}

	string classify(const polygon& p) const {
		bool ans = 0;
		for (int i = 0; i < p.size(); i++) {
			point<T> a = p[i], b = p[(i + 1) % p.size()];
			if (cross(a, b, *this) == 0 && min(a, b) <= *this && *this <= max(a, b))
				return "on";
			if (a.y > b.y) swap(a, b);
			if (a.y <= y && y < b.y && cross(*this, a, b) > 0) ans ^= 1;
		}
		return ans ? "in" : "out";
	}

	friend polygon convex_hull(const vector<point>& pts) {
		point pivot = *min_element(all(pts));
		auto sorted = pts;
		sort(all(sorted), [&pivot](const point& p, const point& q) {
			T cp = cross(pivot, p, q);
			if (cp != 0) return cp > 0;
			return pivot.dist(p) < pivot.dist(q);
			});

		int j = 0;
		polygon res(pts.size());
		for (const point& p : sorted) {
			while (j > 1 && cross(res[j - 2], res[j - 1], p) <= 0)
				j--;
			res[j++] = p;
		}
		res.erase(res.begin() + j, res.end());
		return res;
	}

	// twice the signed area
	friend T area(const polygon& p) {
		T a = 0;
		for (int i = 0; i < sz(p); i++)
			a += cross(p[i], p[i + 1 < sz(p) ? i + 1 : 0]);
		return a;
	}
};


//////////////////////////////////////////////////////////
template<typename T>
int SIZE(T(&t)) {
	return t.size();
}

template<typename T, size_t N>
int SIZE(T(&t)[N]) {
	return N;
}

string to_string(char t) {
	return "'" + string({ t }) + "'";
}

string to_string(bool t) {
	return t ? "true" : "false";
}

string to_string(const string& t, int x1 = 0, int x2 = 1e9) {
	string ret = "";
	for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
		ret += t[i];
	}
	return '"' + ret + '"';
}

string to_string(const char* t) {
	string ret(t);
	return to_string(ret);
}

template<size_t N>
string to_string(const bitset<N>& t, int x1 = 0, int x2 = 1e9) {
	string ret = "";
	for (int i = min(x1, SIZE(t)); i <= min(x2, SIZE(t) - 1); ++i) {
		ret += t[i] + '0';
	}
	return to_string(ret);
}

template<typename T, typename... Coords>
string to_string(const T(&t), int x1 = 0, int x2 = 1e9, Coords... C);

template<typename T, typename S>
string to_string(const pair<T, S>& t) {
	return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}

template<typename T, typename... Coords>
string to_string(const T(&t), int x1, int x2, Coords... C) {
	string ret = "[";
	x1 = min(x1, SIZE(t));
	auto e = begin(t);
	advance(e, x1);
	for (int i = x1, _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
		ret += to_string(*e, C...) + (i != _i ? ", " : "");
		e = next(e);
	}
	return ret + "]";
}

template<int Index, typename... Ts>
struct print_tuple {
	string operator() (const tuple<Ts...>& t) {
		string ret = print_tuple<Index - 1, Ts...>{}(t);
		ret += (Index ? ", " : "");
		return ret + to_string(get<Index>(t));
	}
};

template<typename... Ts>
struct print_tuple<0, Ts...> {
	string operator() (const tuple<Ts...>& t) {
		return to_string(get<0>(t));
	}
};

template<typename... Ts>
string to_string(const tuple<Ts...>& t) {
	const auto Size = tuple_size<tuple<Ts...>>::value;
	return print_tuple<Size - 1, Ts...>{}(t);
}

void dbgr() { ; }
template<typename Heads, typename... Tails>
void dbgr(Heads H, Tails... T) {
	cout << to_string(H) << " | ";
	dbgr(T...);
}

void dbgs() { ; }
template<typename Heads, typename... Tails>
void dbgs(Heads H, Tails... T) {
	cout << H << " ";
	dbgs(T...);
}


/*
consider __VA_ARGS__ as a whole:
dbgv() prints values only
dbg() prints name and values
*/
#define dbgv(...) cout << to_string(__VA_ARGS__) << endl;

#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgv(__VA_ARGS__);

/*
consider __VA_ARGS__ as a sequence of arguments:
dbgr() prints values only
dbgm() prints names and values
*/
#define dbgr(...) dbgr(__VA_ARGS__); cout << endl;

#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);

/*
dbgs() prints only values separated by spaces
*/

/*
compact version
template<typename T> int SIZE(T (&t)){ return t.size(); } template<typename T, size_t N> int SIZE(T (&t)[N]){ return N; } string to_string(char t){ return "'" + string({t}) + "'"; } string to_string(bool t){ return t ? "true" : "false"; } string to_string(const string &t, int x1=0, int x2=1e9){ string ret = ""; for(int i = min(x1,SIZE(t)), _i = min(x2,SIZE(t)-1); i <= _i; ++i){ ret += t[i]; } return '"' + ret + '"'; } string to_string(const char* t){ string ret(t); return to_string(ret); } template<size_t N> string to_string(const bitset<N> &t, int x1=0, int x2=1e9){ string ret = ""; for(int i = min(x1,SIZE(t)); i <= min(x2,SIZE(t)-1); ++i){ ret += t[i] + '0'; } return to_string(ret); } template<typename T, typename... Coords> string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C); template<typename T, typename S> string to_string(const pair<T, S> &t){ return "(" + to_string(t.first) + ", " + to_string(t.second) + ")"; } template<typename T, typename... Coords> string to_string(const T (&t), int x1, int x2, Coords... C){ string ret = "["; x1 = min(x1, SIZE(t)); auto e = begin(t); advance(e,x1); for(int i = x1, _i = min(x2,SIZE(t)-1); i <= _i; ++i){ ret += to_string(*e, C...) + (i != _i ? ", " : ""); e = next(e); } return ret + "]"; } template<int Index, typename... Ts> struct print_tuple{ string operator() (const tuple<Ts...>& t) { string ret = print_tuple<Index - 1, Ts...>{}(t); ret += (Index ? ", " : ""); return ret + to_string(get<Index>(t)); } }; template<typename... Ts> struct print_tuple<0, Ts...> { string operator() (const tuple<Ts...>& t) { return to_string(get<0>(t)); } }; template<typename... Ts> string to_string(const tuple<Ts...>& t) { const auto Size = tuple_size<tuple<Ts...>>::value; return print_tuple<Size - 1, Ts...>{}(t); } void dbgr(){;} template<typename Heads, typename... Tails> void dbgr(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgr(T...); } void dbgs(){;} template<typename Heads, typename... Tails> void dbgs(Heads H, Tails... T){ cout << H << " "; dbgs(T...); }
#define dbgv(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgv(__VA_ARGS__);
#define dbgr(...) dbgr(__VA_ARGS__); cout << endl;
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);
*/




int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll k; cin >> k;

	ll x = 7;
	set<ll> s;
	ll n = 1;
	while (true) {
		if (s.count(x)) {
			break;
		}
		if (x % k == 0) {
			cout << n << endl;
			return 0;
		}
		s.insert(x);
		x *= 10;
		x += 7;
		x %= k;
		++n;
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 50500