import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    System.out.println(getMinBagNum(n));
}

public static int getMinBagNum(int n){
    ArrayList<Integer> list = new ArrayList<>();
    for(int i=0; i<=n/8; i++){
        double x = ((double)(n-8*i)/6);
        double temp = Math.abs(x-Math.round(x));
        if( temp<0.0000000001 ){
            list.add(Integer.valueOf( (int)(x+i) ));
        }
    }
    if(list.size()==0){
        return -1;
    }
    else{
        return Collections.min(list).intValue();
    }
}

}