A = int(input().strip()) print(-1 if (A <= 7 or A % 7 == 0) else A - 7)