var line=''

while(line=readline()){
    line=parseInt(line)
    var sum=0
    if(line!==0){
        while(line>=3){
            var bottomCount=parseInt(line/3)
            sum+=bottomCount
            line=bottomCount+(line%3)
        }
        if(line===2) sum++
        console.log(sum)
    }else{
        break
    }
    
}