#include <iostream>

using namespace std;

int main() {
    int n;

    while (cin >> n) {
        // 由于 n 可能很大 写出完整的 杨辉三角不显示,会导致内存占用过大;
        //    找规律
/*
        1   - 1
        2   - 1

        3   2
        4   3
        5   2
        6   4

        7   2
        8   3
        9   2
        10  4

        11  2
        12  3
        13  2
        14  4

        从头 3 开始重复出现 2 3 2 4 2 3 2 4
*/
    if(n <3){
        cout << -1 <<endl;
    }else {
        int c = n % 4;
   
        if(c == 3 || c == 1 ){
             cout << 2 << endl;
            
        }else if(c == 0){
             cout << 3 << endl;
        }else if(c == 2){
            cout << 4<< endl;
        }

    }
    
    }

    return 0;
}