def main(): N = int(input()) import math def sieve_of_eratosthenes(n): prime = [True]*(n+1) prime[0] = False prime[1] = False sqrt_n = math.ceil(math.sqrt(n)) for i in range(2, sqrt_n+1): if prime[i]: for j in range(2*i, n+1, i): prime[j] = False prime = [i for i in range(2, n + 1) if prime[i]] return prime a = set() b = [] num = sieve_of_eratosthenes(N) dp = [[-1]*N for _ in range(len(num))] dp[0][1] = 1 a.add(2) b.append(2) for i in range(1, len(num)): for j in b: dp[i][j-1] = max(dp[i][j-1], dp[i-1][j-1]) if j + num[i] <= N: dp[i][j+num[i]-1] = max(dp[i][j+num[i]-1], dp[i-1][j-1]+1) if j+num[i] not in a: a.add(j+num[i]) b.append(j+num[i]) print(dp[-1][N-1]) if __name__ == '__main__': main()