class A{static{try{for(int i=0,j,z=System.in.read()&7,k=z*6-2;i3*Math.max(z-i-1,i-3*z)?(i*3+j)%6:5));System.out.println();}}catch(Exception e){}}}