(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read)))
    (format t "~d~%" (if (zerop (mod n 9)) 9 (mod n 9)))))

(main)