import strutils

let n = parseInt readLine stdin

echo case n mod 3
  of 1: 2
  of 2: 1
  else: 0