#include <stdio.h>

/*
写几行就可以发现规律:
n==1或2时,没有偶数,cout<<-1;
n==3时,index=2;
n==4,index=3;
n==5,index=2;
n==6,index=4;
n==7,index=2;
n==8,index=3;
n==9,index=2;
n==10,index=4;
偶数出现的位置都是2324
*/
int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        int flag;
        if (n == 1 || n == 2)
            flag = -1; //没有
        else if (n % 2 == 1) //奇数行都是2
            flag = 2;
        else if (n % 4 == 0) //4的倍数都是3
            flag = 3;
        else if (n % 4 == 2)
            flag = 4;
        printf("%d", flag);
    }

}