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) dp[0] = 0 for p in plist: for i in range(n,-1,-1): if i+p <= n and dp[i] != -1: dp[i+p] = max(dp[i+p], dp[i]+1) print(dp[n])