import java.io.*;
import java.util.*;

public class Main {
    // 这里是有规律的
    // -1 -1 2 3 2 4 2 3 2 4 ...
    private static int[] arr = {2, 3, 2 ,4};

    public static void main (String [] args) throws IOException {
        // Use BufferedReader rather than RandomAccessFile; it's much faster
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        String line = null;
        while ((line = f.readLine()) != null)
        {
            int n = Integer.parseInt(line);
            if (n < 3) {
                out.println(-1);
            }
            else {
                out.println(arr[(n - 3) % 4]);
            }
        }
        out.close();
        f.close();
    }
}