while 1 {puts [expr ~([gets stdin]**4)%10%6]}