print((function (i) return i~=0 and ("28571"):sub(i,i) or 4 end)(io.stdin:read("*n")%6))