import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        if(n<=2){
            System.out.println(-1);
        }else{
            if(((n-1)%4 == 2) || ((n-1)%4 == 0)){
                System.out.println(2);
            }else if((n-1)%4 == 3){
                System.out.println(3);
            }else if((n-1)%4 == 1){
                System.out.println(4);
            }
        }
    }
}