import sys
data=int(sys.stdin.readline())
def love(max):
    for i in range(0,max+1):
        for j in range(0,max+1):
            if i*6+j*8==data:
                print(i+j)
                return i+j
    print(-1)
    return -1
love(data)