import java.io.*; import java.util.Scanner; public class Main_yukicoder750 { private static Scanner sc; private static Printer pr; private static void solve() { String n27 = "285714"; int n = sc.nextInt(); int MOD = n27.length(); pr.println(n27.charAt((n - 1) % MOD)); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }