def seachPrimeNum(N): max = int(N ** 0.5) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum N = int(input()) if N == 1: print(-1) exit() PL = seachPrimeNum(N) X = [0] * (N + 1) Q = {0} for p in PL: for q in sorted(list(Q),reverse = True): if p + q > N: continue X[p + q] = max(X[p + q], X[q] + 1) Q.add(p + q) if X[N] > 0: print(X[N]) else: print(-1)