def create_prime_list(limit): x = limit**0.5 primes = [] #print('x={0}'.format(x)) nums = [x for x in range(2, limit+1)] while nums[0]<=x: primes.append(nums[0]) current_prime = nums[0] nums = [x for x in nums if x%current_prime != 0] primes.extend(nums) return primes n = int(input()) if n == 1: print(-1) exit() plist = create_prime_list(n) dp = [[-1]*(n+1) for _ in range(len(plist))] for i,p in enumerate(plist): dp[i][p] = 1 for i in range(len(plist)): for S in range(1,n+1): if dp[i-1][S] >= 1: dp[i][S] = max(dp[i-1][S], dp[i][S]) if S-plist[i] >= 0 and dp[i-1][S-plist[i]] >= 1: dp[i][S] = max(dp[i-1][S-plist[i]]+1, dp[i][S]) print(dp[len(plist)-1][n])