#include <iostream>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    if (!(cin >> n)) return 0;
  
    // 过滤掉所有无解的情况:奇数,以及 2, 4, 10
    if (n % 2 != 0 || n == 2 || n == 4 || n == 10) {
        cout << -1 << '\n';
    } 
    // 能被 8 整除
    else if (n % 8 == 0) {
        cout << n / 8 << '\n';
    } 
    // 不能被 8 整除的其他合法偶数
    else {
        cout << n / 8 + 1 << '\n';
    }
    return 0;
}

阿巴阿巴阿巴……