import java.util.Scanner; public class prog { public static void main (String[] args) throws java.lang.Exception { Scanner scanner = new Scanner(System.in); Integer n = Integer.parseInt(scanner.nextLine()); int res = 1; for (int i = 2; i < n; i++) { res = (res * i) % n; } System.out.println(res); scanner.close(); } }