#include #include #include int main(void){ int n; scanf("%d",&n); n=n%6; if(n==0){printf("2\n");} else if(n==1){printf("8\n");} else if(n==2){printf("5\n");} else if(n==3){printf("7\n");} else if(n==4){printf("1\n");} else if(n==5){printf("4\n");} }