import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.valueOf(scan.nextLine().trim());
if (n == 1 || n == 2) {
System.out.println(-1);
} else if (n % 2 != 0) {
System.out.println(2);
} else {
System.out.println(n / 2 % 2 == 0 ? 3 : 4);
}
}
}