#include <iostream> #include <queue> #include <vector> using namespace std; //简单背包问题 const int INF = 0x3f3f3f3f; const int MAXV = 100000 + 10; int main() { int n; if (!(cin >> n)) return 0; vector<int> dist(MAXV, INF); queue<int> q; dist[0] = 0; q.push(0); while (!q.empty()) { int u = q.front(); q.pop(); if (u == n) break; for (int step : {6, 8}) { int v = u + step; if (v <= n && dist[v] == INF) { dist[v] = dist[u] + 1; q.push(v); } } } cout << (dist[n] == INF ? -1 : dist[n]) << endl; return 0; }