#include <stdio.h>

int main() {
    int n, pos;
    while(scanf("%d", &n) != EOF) {
        if (n==1 || n==2) {
            pos = -1;
        } else if (n%2 == 1) {
            pos = 2;
        } else if (n%4 == 0) {
            pos = 3;
        } else if (n%4 == 2) {
            pos = 4;
        }
        printf("%d\n", pos);
    }
    return 0;
}