import java.util.; import java.io.; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ int num = Integer.parseInt(str); if(num < 3){ System.out.println(-1); continue; } if(num % 4 == 1 || num % 4 ==3){ System.out.println(2); continue; } if(num % 4 == 0){ System.out.println(3); continue; } if(num % 4 == 2){ System.out.println(4); continue; } } } }