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

using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

void solve()
{
	int n,MIN=-1;
	cin >> n;
	if(n<6)//小于6绝对不行
	{
		cout << MIN;
		return;
	}
	for(int i=0;;i++)//暴力找方案
	{
		int temp=i*8;
		if(n-temp<0) break;
		if((n-temp)%6==0) MIN=i+(n-temp)/6;
	}
	cout << MIN;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin >> t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}