Given the function $f$ defined as follows: \[ f(0) = 0, \] \[ f(1) = 1, \] and for every integer $n \geq 1$, \[ f(3n-1) = f(n) - 1, \] \[ f(3n) = f(n), \] \[ f(3n+1) = f(n) + 1. \] Find the value of $f(2011)$.

Let's think step by step and output the final answer within \boxed{}.
user