const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here let arr = []; for(let i = 0 ; i < 10 ; i++){ const total = parseInt(await readline()); if(total) { let sum = total; let res = 0; while(sum >=3) { const rest = sum % 3; res += Math.floor(sum / 3); sum = Math.floor( sum / 3) + rest; } if(sum >= 2) res++; console.log(res) }else { break; } } }()