import java.util.Scanner; public class test { public static void main(String[] args) { short b[] = {2,8,5,7,1,4}; Scanner s = new Scanner(System.in); String string = s.nextLine(); System.out.println(b[Integer.parseInt(string)%6]); s.close(); } }