#include #include #include int snt(int a, int arr[], int max) { int i; for (i = 1; i <= max; i++) { if (a == arr[i]) { return 1; } } return 0; } int findMax(int a, int b) { return a > b ? a : b; } int f[20000][30000] = {}; const int inf = -INT_MAX; int main() { int n; int i, j; int max; int check[21000] = {}; int arr[20000] = {}; scanf("%d", &n); for (i = 2; i <= sqrt(n); i++) { for (j = 2; j <= n / i; j++) { check[i*j] = 1; } } max = 1; for (i = 2; i <= n; i++) { if (!check[i]) arr[max++] = i; } max--; for (i = 1; i <= n; i++) { f[0][i] = inf; } for (i = 1; i <= max; i++) { for (j = 0; j <= n; j++) { if (j - arr[i] >= 0) { f[i][j] = findMax(f[i - 1][j], f[i - 1][j - arr[i]] + 1); } else { f[i][j] = f[i - 1][j]; } } } int result = (f[max][n] <0 ? -1 : f[max][n]); printf("%d", result); getchar(); getchar(); return 0; }