import java.util.Scanner; public class No744 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String sample = "285714"; // n=4なら4%6 = 0..4なので4桁目の"7" String ans = sample.substring( (n-1)%6, n%6 ); System.out.println( ans ); } }