import math N = int(input()) dic = {i: True for i in range(2, N + 1)} for i in range(2, int(math.sqrt(N)) + 1): if dic[i] is False: continue j = i * 2 while j <= N: dic[j] = False j += i primes = [i for i in dic.keys() if dic[i]] del dic dp = [[0] + [-1] * N for i in range(len(primes) + 1)] for i in range(len(primes)): for w in range(N + 1): if w + primes[i] <= N and dp[i][w] != -1: dp[i + 1][w + primes[i]] = dp[i][w] + 1 dp[i + 1][w] = max(dp[i][w], dp[i + 1][w]) possible_values = (i[N] for i in dp) print(max(possible_values))