#include<iostream>
#include<vector>

using namespace std;

int  FindIndex(int n)
{
    if(n<=2)
    cout<<-1<<endl;
    else if(n%4==1||n%4==3)
    cout<<2<<endl;
    else if(n%4==2)
    cout<<4<<endl;
    else 
    cout<<3<<endl;
    return 0;
}

int main()
{
    int n;
    while(cin>>n)
    {
        int res=FindIndex(n);
        //cout<<res<<endl;
    }
    return 0;
}
int  FindIndex(int n)
{
    int Index[]={4,2,3,2};
    int res=-1;
    if(n>2)
    res = Index[(n-2)%4];
    cout<<res<<endl;
    return 0;
}