# https://yukicoder.me/problems/931 import math N = int(input()) is_prime = [True for _ in range(N + 1)] is_prime[0] = is_prime[1] = False prime_list = [] for i in range(2, N + 1): if is_prime[i]: prime_list.append(i) for j in range(i * i, N + 1, i): is_prime[j] = False dp = [-1 for _ in range(N + 1)] dp[0] = 0 for i in prime_list: for j in range(N, i - 1, -1): if dp[j - i] != -1: dp[j] = max(dp[j - i] + 1, dp[j]) print(dp[N]) # print(dp)