print((function (n) local s,i="285714",n%6 if i==0 then i=6 end return s:sub(i,i) end)(io.stdin:read("*n")))