import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); sc.close(); String tmp = "285714"; System.out.print(tmp.charAt((N - 1) % 6)); } }