import sys
input = sys.stdin.readline
N = int(input().rstrip())
arr = [3, 5]
d = [5001] * (N + 1)
d[0] = 0
for i in range(N + 1):
for weight in arr:
if i >= weight:
if d[i - weight] != 5001:
d[i] = min(d[i], d[i - weight] + 1)
if d[N] == 5001:
print(-1)
else:
print(d[N])