import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
//找规律,对4取余,余数为1 3 结果是2,余数为0 ,结果是3 余数为2结果是4
if(n==1 || n==2){
System.out.println(-1);
//continue;
}else if(n%4==1 || n%4==3){
System.out.println(2);
//continue;
}else if(n%4==0){
System.out.println(3);
//continue;
}else if(n%4==2){
System.out.println(4);
//continue;
}
}
}
}